Why does my app crash when I add an row to the table view?
- by mystify
I'm adding a row like this, when a button is pressed. It must be the very first row in the first section:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
I don't call anything else here. No -reloadData. I keep getting this:
* 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 (6)
must be equal to the number of rows
contained in that section before the
update (6), plus or minus the number
of rows inserted or deleted from that
section (1 inserted, 0 deleted).'