I'm new to Objective-C. So I have a Table View with 5 rows in the section (5 cells), and I want to allow the user to delete them, but the app keeps crashing when I click on the delete button. The reason it crashes is because I have 5 rows in the section instead of returning [self.myListItems count] How do I correct this code below while keeping the 5 rows in the section?
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[self.myListItems removeObjectAtIndex:indexPath.row];
[self saveList];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
The error is: Assertion failure in -[UITableView _endCellAnimationsWithContext:]