Using Core Data, I have my fetchedResultsController with a with a date field.
I want to display two sections according to the date: if it’s a date in the future I want to display it in the section active, otherwise in the non Active section.
Besides I want between the two sections I want to display a “draft section”.
It is also important to mention that inside each section, I want them sorted by date.
1) Can I still use the fetchedResultsController? or will I need to create 3 different arrays?
2) Does the field used on sectionNameKeyPath need to be a String?
Edit:
3) Can I set the order of my sections other than alphabetically?
Edit 2:
for 3) Sections are not ordered alphabetically. How to fix the order of the sections if they’re in no way related to the NSSortDescriptor I set to my fetchRequest?
Thanks in advance.
If you are using custom objects for your NSManagedObjects then all you really need to do is define a method that returns which section it should be in. Not sure what you mean by draft section but as long as the NSManagedObject subclass has a method that generates “Draft” then you should be fine.
To sort by date within a section simply add the sort descriptor to the fetch request. Simple as that.
I’ve done a similar thing in one of my Apps so if you have any other questions do ask.
You also want to look at subclassing NSFetchedResultsController if you want to customize the creation of sections and index titles. It’s all in the docs.
For part 3) there are a couple of ways
1 Might seem a bit more kludgy but is probably what I would try first.