问题描述
实现四个委托方法有什么好处:
What advantage is there to implementing the four delegate methods:
-
(void)controllerWillChangeContent:(NSFetchedResultsController *)controller
(void)controllerWillChangeContent:(NSFetchedResultsController *)controller
(void)controller:(NSFetchedResultsController *)controller didChangeSection:(id)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
(void)controller:(NSFetchedResultsController *)controller didChangeSection:(id )sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
(void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath
(void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath
(void)controllerDidChangeContent:(NSFetchedResultsController *)controller
(void)controllerDidChangeContent:(NSFetchedResultsController *)controller
而不是实现:
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
任何帮助表示赞赏//:)
Any help appreciated // :)
推荐答案
在使用时FetchedResultsContr借助表视图,您可以实现这四个委托方法以响应对获取的结果所做的每个更改,并在表中发生更改时对其进行动画处理。但是,作为NSFetchedResultsControllerDelegate 状态:
When you're using the FetchedResultsController with a table view, you can implement those four delegate methods to respond to each change made to your fetched results, and animate the changes as they occur in your table. However, as the NSFetchedResultsControllerDelegate documentation states:
因此,如果您要进行大量更改,则可以实现controllerDidChangeContent并使用 [self .tableView reloadData]
。
So if you're doing a bunch of changes, you can just implement controllerDidChangeContent and respond to all of them at once using something like [self.tableView reloadData]
.
这篇关于是否为Core Data的获取结果控制器实现委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!