在我的核心数据应用程序中,我使用的是 FetchedResultsController。通常要为 UITableView 中的标题设置标题,您将实现以下方法,如下所示:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#> sections] objectAtIndex:section];
return [sectionInfo name];
}
其中 [sectionInfo name] 返回一个 NSString。
我的 sectionKeyPath 基于 NSDate,除了它给我的部分标题是原始日期描述字符串(例如 12/12/2009 12:32:32 +0100)之外,这一切都很好,看起来有点乱头!
因此,我想在此使用日期格式化程序来制作一个不错的标题,例如“2010 年 4 月 17 日”,但我不能使用 [sectionInfo name] 来做到这一点,因为这是 NSString!有任何想法吗?
非常感谢