I'm making a sectioned table with fetched results, but am having a hard time getting custom sections worked out.
Normally one would just have an attribute to sort by, and use sectionNameKeyPath:
to generate the sections. But my sorting attribute is calculated on the fly, and I can't seem to get the fetchedResultsController
to use it correctly...
Update: Using jbrennan's advice below, I'm really close to the intended functionality. I've added a Category to NSDate
that returns a "days ago" number; putting that in here gives me sections based on those numbers:
NSFetchedResultsController *aFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:managedObjectContext
sectionNameKeyPath:@"myDateAttribute.daysAgo"
cacheName:@"Root"];
Here's where I'm stuck: I don't need them sorted by "days ago," I need them sorted via some calculations based on other attributes in the entity. So I can't just call that custom Category method, I need to call a method with arguments, like so:
[myDateAttribute sortingRoutine:thisObject.value]
Or something like that. I hope that makes some degree of sense. Thanks a ton if you can help :)