Alan
Alan

Reputation: 9471

XCode Error: uncaught exception 'NSInternalInconsistencyException'

What exactly does this mean?

* 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 (2) 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 (1 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's confusing... I am getting this error when I am reloading a UITableview. What update is this talking about? I can't remove or add cells ?

Upvotes: 0

Views: 475

Answers (1)

user524261
user524261

Reputation: 498

What it's telling you is that the value returned by - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section is not in sync with the actual number of rows in that section. Have you maybe hard wired the number of rows in this section and are then programatically deleting rows without updating it in this method?

If you look at the message, it thinks there should be 2 rows now, but you previously had 1, then inserted 1 and deleted 1, which means the net effect should be 1 row.

Upvotes: 2

Related Questions