第一个,请确保您创建您的抓取结果控制器时,瞬态属性仅用于sectionNameKeyPath
。最好命名为sectionIdentifier
(正如Apple在其示例代码中所做的那样)。实际日期应该是您实体的单独属性。 (我将其称之为dateAttribute
二,请确保您在Entity.m文件中指定的关键路径依赖:
+ (NSSet *)keyPathsForValuesAffectingSectionIdentifier {
// If the value of dateAttribute changes, the section identifier may change as well.
return [NSSet setWithObject:@"dateAttribute"];
}
三,确保在你的控制器,你作出适当的反应在管理对象方面的变化通过
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
if (!self.tableView.editing) [self.tableView reloadData];
// the quick and dirty method without animations;
// see referenced code for a more pleasant approach
}
如果有不清楚的地方,看看苹果的例子DateSectionTitles。
如何传播更新? NSFetchedResultsController委托? – Mundi 2012-08-04 21:07:01
是的,我认为是。 – mhbdr 2012-08-04 21:27:28
对于SQlite商店,您可能不适用于排序描述符的瞬态属性。 – 2012-08-05 06:55:14