I have a NSFetchedResultsController
which is fetching objects from a NSManagedObjectContext
. I'm using the results to populate a UITableView.
I'm filtering with these two sort descriptors.
NSSortDescriptor *lastOpened =
[[NSSortDescriptor alloc] initWithKey:@"lastOpened" ascending:NO];
NSSortDescriptor *titleDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES];
And when I create the NSFetchedResultsController
, I sort the sections via sectionNameKeyPath:@"lastOpened"
.
Right now my sections display the standard format like 2009-07-02 20:51:27 -0400 and since no two can be opened at the same time, they are all unique. I need them to cover range of date/times, such as an entire day, and be in a human-readable form. Something like Thursday, July 2.
Thanks!
Edit:
This is all inside a UITableViewController
. Here's some more code.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
// Display the dates as section headings.
return [[[fetchedResultsController sections] objectAtIndex:section] name];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
}