Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting NSFetchedResultsController's sections array

Is there a way to sort the sections property of NSFetchedResultsController? Let's say i don't want my sections to be sorted alphabetically ascending, but descending. Or maybe not even alphabetically but ascending by the number of rows in a section.

I can imagine that sorting the array directly isn't a good idea, since NSFetchedResultsController created and filled it for me..

like image 200
bijan Avatar asked Jul 03 '26 22:07

bijan


1 Answers

"1) use a transient property that joins the property to sort by and the property that will be displayed as the title and specified in the sectionNameKeyPath and

2) then use the UITableViewDelegate titleForHeaderSection to extract the name from the value."

more here: http://machine501.com/blog/2011/04/26/uitableview-section-sorting-a-hack/

like image 168
alhcr Avatar answered Jul 06 '26 10:07

alhcr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!