Previously had the sort by date, section by day working properly, using a transient method for the sectionNameKeyPath with an NSFRC. Similar to this solution: How to Group by day in NSDate with NSPredicate - needed to create multiple UITableView sections
However once the number of records became large, I wanted to add in batching to my NSFRC. The batching didn't work, because it has to fetch every record and run the transient method to determine the sections. See: NSFetchedResultsController is loading all rows even through I have batch set
In fact if you check out apple's sample code often linked to for this, you'll note that the batching doesn't actually work correctly. It fetches all the rows right away to run the transient method. https://developer.apple.com/library/ios/samplecode/DateSectionTitles/Introduction/Intro.html
I'm not quite sure where to go from here. The grouping by day is fairly critical, but so is the batching.
Update
I tried one solution, pre-calculating the Day String and adding it to the data model. So all of my models have both a .created
nsdate and a .createdDayString
. I sort by created
, and tried to use the createdDayString
as the sectionNameKeyPath
, but while the records are in the correct order, it sections (groups) them incorrectly, apparently using the Alphabetical order of the Day names. e.g. the first sections are all the Wednesdays.
Solution with pre-calculating
As an update to my solution, if I calculate and store the same values that Apple was in their example (except with date, as shown in this SO post: How to Group by day in NSDate with NSPredicate - needed to create multiple UITableView sections) then I can use that as the sectionNameKeyPath
. That works, but it does mean storing more data on the core data objects solely for this purpose. Leaving this open in case someone has a brilliant solution.