0

I have an iPad app with ARC, storyboards, supporting ios5+.

I have a VC that is working with NSFetchedResultsController on its own. The VC has two tableviews pointing at two different entities. I have single record add, change, delete, and moving of rows working fine on this VC.

I've now introduced a new feature to enable the user to quick add multiple rows to these tableviews. I do this by providing a segue (modal) from this VC to a new VC (lets call it quickAddVC). The user enters the data on quickAddVC, and then I segue back (modal) to the original VC. I save the new records (via an alternate call) before (I believe) setting up the NSFetchedResultsControllers for the VC again (I set them to nil in ViewDidUnload).

However I keep getting this mismatch error. Somehow it keeps registering the number of inserts that occur from the quickAddVC as 1 insert no matter how many records I add, and it somehow remembers how many records were in the NSFetchedResultsControllers before my segues to do this comparison.

Error:

* Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-2372/UITableView.m:1070

Failure in didChangeObject, name=NSInternalInconsistencyException reason=Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (5) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

Any ideas on what I am doing wrong or should try would be useful.

I can't figure out how to get the NSFetchedResultsControllers to simply forget its original state and restart from scratch which would I think resolve this issue for me.

I haven't posted any of the code, I guess I could post a lot if needed but hoping there is enough here to outline the design issue and get some ideas.

4

1 に答える 1

1

回答を再投稿して、質問をクローズ済みとしてマークするだけです。

問題は解決しました。基本的に、間違った場所で NSFetchedResultsControllers をクリアしていました。セグエの直前にそれらを nil に設定すると、すべて正常に動作します。私は、ViewDidLoad メソッドが呼び出されていることを考えると、ViewDidUnload メソッドも呼び出されていると誤って仮定していましたが、そうではありませんでした。

于 2012-10-09T07:54:15.483 に答える