【发布时间】:2014-04-26 09:16:54
【问题描述】:
我有一个如下所示的故事板:
摘要列表 -> 递归表视图 -> 项目视图
它由导航控制器管理,最好的部分工作正常,正如我所期望的那样。我可以在摘要列表中毫无问题地编辑数据:
Summary List -> Recursive Table View -> Item View
|
| <- (make a change here, use beginUpdate and endUpdate)
|
Core Data
这个位很好用...
应该发生的是,当进入项目视图时,核心数据对象会更新,然后项目视图将出现在摘要列表的下一次加载中。
但是,由于某种原因,摘要列表仍在后台刷新,我认为是因为它位于导航层次结构中,因此当我在项目视图板上更新 CoreData 对象时,我得到经典的“CoreData:错误:严重应用程序错误。在调用 -controllerDidChangeContent' 期间,从 NSFetchedResultsController 的委托中捕获了一个异常 - 通常我会通过确保调用 beginUpdate 和 endUpdate 来解决这个问题,但是如果我和 tableView 之间可能有许多表视图,我该怎么做有问题?
这个位不起作用:
Summary List -> Recursive Table View -> Item View
| |
| | > (a change here modifies the core
| data database, Summary List is
| still somehow loaded and error)
|
Core Data
完整的错误是经典的“你做错了”:
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
(0) must be equal to the number of rows contained in that section
before the update (1), plus or minus the number of rows inserted or
deleted from that section (0 inserted, 0 deleted) and plus or minus
the number of rows moved into or out of that section (0 moved in, 0 moved out).
【问题讨论】:
-
能否给出错误的全文?
-
现在添加了,不过只是普通的...
-
细节很重要。行和节的编号和计数,以及操作的类型,都有助于诊断正在发生的事情。
-
因此,这认为某个项目已从表格视图的第 1 部分(第二部分)中以某种方式删除。你知道这是哪一个吗?为什么一个项目会从这个部分消失?您的代码的哪些部分可能在这里负责?
-
我知道为什么它被删除了——我不知道如何告诉屏幕外视图控制器为更新做准备。
标签: ios core-data uinavigationcontroller nsfetchedresultscontroller