I'm implementing a UITableView where the number of rows for a given section is limited to 4. For that matter, if the number of rows is less than 4, I add a row that is used as a placeholder for the next item to add (this is similar to the "Contacts" app).
I have a problem when I reach the maximum number of rows for the section. If I try to delete an object from that section, I get the following exception:
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 (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'
Of course, the problem is that my numberOfRowsInSection
methods returns N+1 if the number of rows is less than 4 (one extra cell for the placeholder), which triggers this inconsistency exception.
Is there anyway around this?