I am trying to implement a standard delete of a UITableViewCell using the standard edit control style as described in the Apple Table View Programming Guide. When the following code executes in the commitEditingStyle method
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
I get the following error message
Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Invalid update: invalid number of rows in section 2. The number of rows contained in an existing section after the update (1) 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, 1 deleted).
If it’s the only row, I suggest you delete the section as well. You also need to sync your data source with your table, i.e. delete the row in your data source as well.
Here’s a correct example when the file system is your data source in iOS: