I use NSFetchedResultsController to fetch from database with Core Data. And I have an Entity with 2 properties, prop1 and prop2 of NSString.
How would I sort sections not only by one of the properties but both?
Now it is:
Title1ForProp1/Title2ForProp2 (prop1==1 prop2==2)
Title1ForProp1/Title1ForProp2 (prop1==1 prop2==1)
Title2ForProp1/Title1ForProp2 (prop1==2 prop2==1)
I need:
Title1ForProp1/Title1ForProp2 (prop1==1 prop2==1)
Title1ForProp1/Title2ForProp2 (prop1==1 prop2==2)
Title2ForProp1/Title1ForProp2 (prop1==2 prop2==1)
When you create the fetch request for the NSFC you create the sort descriptor and give the request an array.
You can put as many sort descriptors in the array as you like.
Just create a sort descriptor for each field you want to sort by.
I can remember which order you have to put them into the array though.
OK, so code wise…
This is all you have to do.
The NSFC will only split them into sections if you give it a sectionNameKeyPath. If you don’t want any sections then make the sectionNameKeyPath nil.