【发布时间】:2014-08-24 17:17:15
【问题描述】:
目标: 使用 FRC,将 Section's 按 startDate 排序,NSDate 属性,但希望 Today 的日期 Section 出现在 Upcoming 日期 @987654332 之前@。
我使用瞬态属性 sectionIdentifier 遵循 Apple 的代码。 Apple's sample code。并首先从这个项目开始:OneFRC
我很快意识到仅使用一个 FRC 可能无法做到这一点(我可能错了)。
接下来,我决定尝试使用 3 个 FRC:ThreeFRC。
TableView sections 现在出现在我想要的订单中:
第 0 节:Today
第 1 部分:Upcoming
第 2 部分:Past
但是,添加数据会触发 FRC 委托,我收到以下错误:
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 0.
The number of rows contained in an existing section after the update (4) must be
equal to the number of rows contained in that section before the update (3), 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). with userInfo (null)
再说一次,我希望能够用 1 FRC 实现我的目标,但我似乎不知道如何。
我已经尝试解决这个问题 4 天了!如果这个问题在 SO 上没有得到解决,我想我可能会联系 Apple 以获得开发人员支持。如果我这样做了,我会在此处发布解决方案,以便其他人受益。
项目在 Github 上可用:
编辑
感谢@blazejmar,我能够摆脱rows 错误。但是,现在当我尝试添加 sections 时出现错误。
2014-11-03 16:39:46.852 FRC[64305:60b] CoreData: error: Serious application error.
An exception was caught from the delegate of NSFetchedResultsController during a
call to -controllerDidChangeContent:. Invalid update: invalid number of sections.
The number of sections contained in the table view after the update (2) must be
equal to the number of sections contained in the table view before the update (1),
plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).
with userInfo (null)
在三个 FRC 中重现错误的步骤:
1. Launch App ->
2. Tap Generate Data ->
3. Tap View in FRC ->
4. Tap back to the RootVC ->
5. Change the system date to a month from Today ->
6. Tap View in FRC and only one section `Past` should appear. ->
7. Tap `Add Data`.
8. The error should appear in the log.
【问题讨论】:
标签: ios uitableview core-data ios7 nsfetchedresultscontroller