开发者

UITableView and CoreDate "Invalid update: invalid number of rows in section" After returning from another view and Saving

开发者 https://www.devze.com 2023-04-10 14:56 出处:网络
I have a UITableView that is backed by core data with sections grouped by date.I can delete and add while I\'m on the that view just fine.The NSFetchController and the UITableView stay in sync just fi

I have a UITableView that is backed by core data with sections grouped by date. I can delete and add while I'm on the that view just fine. The NSFetchController and the UITableView stay in sync just fine. But then I drill down to an individual object, make changes, save and return. I don't add from the other view, but sometimes delete, most of the the time I'm just making edits to existing records, and none of the edits would cause them to change which section they belonged to. At that point if I try to delete a row I get:

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:974
2011-10-01 14:55:42.691 Lotus Bud[8073:fa03] Serious application error.  An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:开发者_StackOverflow社区.  Invalid update: invalid number of sections.  The number of sections contained in the table view after the update (1) 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, 1 deleted). with userInfo (null)

What do I need to do to get them back in sync after saving from another view.


I would suggest listening for the NSManagedObjectContextDidSaveNotification and breaking in the debugger when it is fired. Then you can see what section is being deleted and hopefully backtrace to the source of the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号