Hi: Moving rows between sections in Core Data backed UITableView works quite fine after I've implemented a 'userDrivenChange' check in 'controllerDidChangeContent:', as mentioned in the apple docs. But only when moving the last row of a section to another section I get a NSRangeException. There is ob开发者_如何学编程viously a problem when sections get empty. How could I handle that the best way?
Have you implemented the -controller:didChangeSection:atIndex:forChangeType:
method? If not, that may look something like this:
-(void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
switch(type) {
case NSFetchedResultsChangeInsert:
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
break;
}
}
精彩评论