I’m having a problem with my deleting of cells in the tableview , my program simply crashes when i press de delete button.
Here is my code for it :
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the managed object at the given index path
sect = [listArray objectAtIndex:indexPath.row];
[sect removeObjectAtIndex:indexPath.row];
// Update Event objects array and table view
[listArray removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
tableView.editing = YES;
}
}
Remove the following completely:
and
Just call
[listArray removeObjectAtIndex:indexPath.row];then callreloadDatato refresh yourUITableView.