Why does the application crash when I add a row to the table view?

I add a line like this when I click the button. This should be the first line in the first section:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

I don't call anything here. No -reloadData. I keep getting the following:

*** Application termination due to an uncaught exception 'NSInternalInconsistencyException', reason: “Invalid update: invalid number of lines in section 0. number of lines contained in an existing section after update (6) must be equal to the number of lines contained in this section before updating (6), plus or minus the number of rows inserted or deleted from this section (1 inserted, 0 deleted).

0
source share
1 answer

, , tableView . ( ) , , numberOfRowsInSection. insertRowsAtIndexPaths 7 ( ), 6.

+2

Source: https://habr.com/ru/post/1795477/


All Articles