gpt4 book ai didi

iphone - 是否为 Core Data 的获取结果 Controller 实现委托(delegate)

转载 作者:行者123 更新时间:2023-12-03 20:58:38 25 4
gpt4 key购买 nike

实现四种委托(delegate)方法有什么好处:

  • (void)controllerWillChangeContent:(NSFetchedResultsController *) Controller

  • (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)类型newIndexPath:(NSIndexPath *)newIndexPath

  • (void)controllerDidChangeContent:(NSFetchedResultsController *) Controller

而不是实现:

  • (void)controllerDidChangeContent:(NSFetchedResultsController *) Controller

感谢任何帮助//:)

最佳答案

当您将 FetchedResultsController 与 TableView 一起使用时,您可以实现这四个委托(delegate)方法来响应对所获取结果所做的每个更改,并在表中发生更改时以动画形式呈现。但是,作为 NSFetchedResultsControllerDelegate documentation 状态:

It may be computationally expensive to animate all the changes. Rather than responding to changes individually (as illustrated in “Typical Use”), you could just implement controllerDidChangeContent: (which is sent to the delegate when all pending changes have been processed) to reload the table view

因此,如果您要做大量更改,您只需实现controllerDidChangeContent 并使用诸如[self.tableView reloadData] 之类的内容立即响应所有更改。

关于iphone - 是否为 Core Data 的获取结果 Controller 实现委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2946385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com