apoorv shah
apoorv shah

Reputation: 171

crash application in deleting tableview

I am using core data. When i delete row (in section there is only one row so indirectly i have to delete section), application is crash and i get following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 4. 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 (0 inserted, 0 deleted).'

I remove object from mutablearray, which i used to popupalate tableview data.Please help me.enter code here

I want to delete section. So i use this function

[self.tableview deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];

Upvotes: 0

Views: 216

Answers (2)

omeraloni
omeraloni

Reputation: 49

Be sure to first delete the section's objects from the data source and only then from the tableview.

Upvotes: 1

Matthias Bauch
Matthias Bauch

Reputation: 90117

did you delete the corresponding cell with something like this?

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

Upvotes: 1

Related Questions