我创建了UITableViewDataSource一个混合了静态和动态部分的内容。我通过NSIndexPath按照您的计划进行修改来做到这一点。重要的是也修改 的NSIndexPath委托方法中的NSFetchedResultsControllerDelegate:
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{
indexPath = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:kSectionWithAdditionalRowIndex];
if (newIndexPath) {
newIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row + 1 inSection:kSectionWithAdditionalRowIndex];
}
[super controller:controller didChangeObject:anObject atIndexPath:indexPath forChangeType:type newIndexPath:newIndexPath];
}
该示例取自我的CBUIFetchResultsDataSource.m类的子类,它是UITableViewDataSource由NSFetchedResultsController. 我还必须覆盖-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section,-(id)objectAtIndexPath:(NSIndexPath*)indexPath和-(NSIndexPath*)indexPathForObject:(id)object.