gpt4 book ai didi

ios - -[UITableView _endCellAnimationsWithContext :] Getting Core Data error while trying to update tableview 中的断言失败

转载 作者:行者123 更新时间:2023-11-29 03:58:09 28 4
gpt4 key购买 nike

应用程序将照片上传到服务器。

当用户选择上传某些照片时,照片的信息将保存到核心数据中。使用 fetchedResultsController 填充一个表格 View ,显示照片列表。

表格 View 包含正在进行的上传、队列中的照片和已完成上传的部分,并根据状态进行相应更新。

但是现在,当我尝试添加另一组要上传的照片时,通过再次选择,而前一组照片仍在上传时,出现以下错误。

此后桌面 View 变为空白。我在桌面 View 中看不到任何内容。

CoreData: error: Serious application error.  An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:.  Invalid update: invalid number of rows in section 1.  The number of rows contained in an existing section after the update (96) must be equal to the number of rows contained in that section before the update (62), plus or minus the number of rows inserted or deleted from that section (21 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). with userInfo (null)

最佳答案

这里发生的情况是,您第一次更新已插入 21 个单元格,并添加到模型中。 TableView 通过调用 tableView:numberOfRowsInSection: 更新其内部模型,这应该返回 83 ( 62 + 21),但您的第二次更新已向模型添加了更多项目,因此它实际上返回 96。

这种情况通常会发生,因为您在主线程之外调用 UIKit 操作(非常糟糕),或者您对模型进行了更改,而没有在同一函数中更新表格 View 。

关于ios - -[UITableView _endCellAnimationsWithContext :] Getting Core Data error while trying to update tableview 中的断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16236726/

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