I have an iPhone 3.0 application that work with requests using Core Data. It has a view with all requests grouped by request status (sectionNameKeyPath:@"status" ). Also it has another view where the user can change the request status.
I have a problem when there is one row/request with in specific group and the user edits the status of that request (so the section to which that row belonged should disappear), the exception is raised on the following code:
//Change the request status. Request is the NSManagedObject
request.status = [NSNumber numberWithInt:Responded];
// Save the context.
NSError *error;
//The exception is raised at the following line
if (![request.managedObjectContext save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
The exception text is the following: 2009-08-18 15:04:55.866 Application[263:20b] *** 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 (8) 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).'
Can anyone explain why I have this exception and how to deal with it?