NSFetchedResultsController titleForHeaderInSection with formatted NSDate
Posted
by Daniel Granger
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Granger
Published on 2010-04-17T21:15:12Z
Indexed on
2010/04/17
21:23 UTC
Read the original article
Hit count: 446
In my Core Data app I am using a FetchedResultsController. Usually to set titles for headers in a UITableView you would implement the following method like so:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#> sections] objectAtIndex:section];
return [sectionInfo name];
}
where [sectionInfo name] returns a NSString.
my sectionKeyPath is based on an NSDate and this all works fine apart from the section headers it gives me are the raw date description strings (e.g. 12/12/2009 12:32:32 +0100) which look a bit of a mess in a header!
So I want to use a date formatter on this to make a nice header like "Apr 17 2010" but I can't do that with the [sectionInfo name] as this is NSString! Any Ideas?
Many Thanks
© Stack Overflow or respective owner