I have a Core Data table and display the record labels in a UITableView in the MasterView of a SplitView. In the DetailsView I display details of the selected item.
I want to be able to filter the MasterView using a search field - and thanks to this site I have that working. However when the filter is being applied I want the user to be able to select an item from the filtered list and make edits to it in the DetailsView.
So far so good - except that as soon as the user tries to save the edits Core Data throws an exception, like the one below. What appears to be happening is that because of the edit the record no longer fits in the search criteria and this causes Core Data some problems.
Any ideas on how to overcome this ? Can I somehow turn off dynamic filtering on the resultsController so that it does not try and change things once the user starts an edit ?
* Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:1070 2013-08-29 14:29:40.155 iProjectiPad[11507:c07] CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. Invalid update: invalid number of rows in section 0. 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 (5), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 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) 2013-08-29 14:29:40.156 iProjectiPad[11507:c07] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. 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 (5), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
It is probably something wrong with the datasource of you're table. It can be the number of rows that is wrong. I think you need to remove the old data from your nsmutable array datasource by
assuming searchCities is your nsmutablearray