my app crashes when the user tries to delete a row from the UITableView and in the debugger I get the SIGABRT error.
Here is my code for deletion:
- (void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[[self displayedObjects] removeObjectAtIndex:[indexPath row]];
// Animate deletion
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[[self tableView] deleteRowsAtIndexPaths:indexPaths
withRowAnimation:UITableViewRowAnimationFade];
//[[self tableView] deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
}
}
I got help in another question. And the problem is that the object would be deleted from the array but then before deleting the row from the table view , the numberOfRowsInSection is called again which then loads the array from disk again and give the number before the deletion due to a problem in my loading of the array. I put a break point at the numberOfRowsInSection and it is all clear now.