I am trying to delete with the following code.
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
Its return multiple exception.
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:1070
2013-01-29 16:28:22.628
Terminating app due to uncaught exception
‘NSInternalInconsistencyException’, reason: ‘Invalid update: invalid
number of rows in section 1. The number of rows contained in an
existing section after the update (5) must be equal to the number of
rows contained in that section before the update (5), plus or minus
the number of rows inserted or deleted from that section (0 inserted,
5 deleted) and plus or minus the number of rows moved into or out of
that section (0 moved in, 0 moved out).’
It is because you should have a dynamic way of returning the number of rows.
For example, I create an 3 arrays. Each with 3 values (these are
NSArrayvariables) :In
.hfile:In
.mfile, viewDidLoad or init or something similar:When returning number of rows in table, I have :
Then, in
cellForRow:Then I delete
@"Dog"by swiping on the table or some other way you want to delete. Then, when reloading the table, your array count will be 2, so the table will “know” that it has to display only 2 rows. Basically, you need to update your data source as well.It applies for the other sections as well. Because you remove elements from arrays, number of rows will be updated also.