ios - NSFetchedResultController 委托的顺序 didChange: atSectionIndex:
问题描述
我有一个奇怪的情况,我问自己是否做错了什么。我分配了一个 NSFetchedResultsController 和一个委托。委托接收到已正确添加部分的函数调用,但消息的顺序似乎未定义。
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>,
didChange sectionInfo: NSFetchedResultsSectionInfo,
atSectionIndex sectionIndex: Int,
for type: NSFetchedResultsChangeType)
假设我的初始提取导致 3 个部分 [0,1,2]。现在我收到有关更改的更新,如下所示:
- sectionIndex 4 的 .insert 操作
- sectionIndex 3 的 .insert 操作
我正在尝试根据更改跟踪视图模型,所以我不知道我需要在这里做什么。如何在添加第 3 节之前添加第 4 节。问题是,如果我只添加一个占位符第 3 节,然后添加第 4 节4.
文档说明了订单,但我希望更新是有序的,以便我可以跟踪对本地数组的更改。
任何提示表示赞赏。
解决方案
NSFetchedResultsController
专门设计/实现/测试以驱动UITableView
. 从文档:
While table views can be used in several ways, fetched results controllers primarily assist you with a primary list view.
要回答您的问题,我认为您没有做错任何事情,但我认为您正在尝试对UITableView
' 实施中的一些秘密进行逆向工程。
推荐阅读
- c# - .Net Core Web 应用程序的自定义服务扩展不映射相同
- vb.net - 为什么我的代码在单步执行时可以工作,但在正常运行时却不行?
- sql - Microsoft Access 查询 - 将两个查询合并为一个
- php - PHP / MYSQL中的android请求JSON响应
- ubuntu-18.04 - Choregraphe 软件无法启动
- c# - 如果路径中的目录不存在,CloudFile.Exists()/ExistsAsync() 会抛出 403(未经授权)?
- python - 一次订购多个列表,其中一个作为基本参考
- swift - 如何在 Swift 中同时进行 SFSpeechRecognition 和录制音频?
- visual-studio-code - 扩展 vscode 智能感知
- python - 如何将 Asctime 显示为可视图形