Is it not possible to remove several rows from UITableView while adding no new rows? I thought there was support for batch insertion and deletion but it appears that you can only adjust the table size by 1 item from the previous count.
When I attempt to remove a whole bunch of rows without adding anything new, I get the error:
Invalid update: invalid number of rows in section 2. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted).'
This is how I'm doing the deletes:
// The section initially has 7 rows. I want to remove 5 of them.
// The underlying table store data has been cleared of the 5 rows
// content as of this point
int newRowCount = 5;
int aSection = 2;
// Create the index paths of the rows I want to delete
NSMutableArray *deletePaths = [NSMutableArray arrayWithCapacity:newRowCount];
for (int ix = 0; ix < newRowCount; ++ix)
{
[deletePaths addObject:[NSIndexPath indexPathForRow:ix inSection:aSection]];
}
// Start the updates
[aTableview beginUpdates];
if (deletePaths && [deletePaths count] > 0)
{
[aTableview deleteRowsAtIndexPaths:deletePaths
withRowAnimation:UITableViewRowAnimationNone];
}
[aTableview endUpdates];
Apple's UITableView Documentation I'm following: link text