Reputation: 1031
I have a tableView that I want to allow editing and delete rows. I make it go into editing mode fine. But when I press the delete button it's not firing off the event to make it delete the row?
Here is my code:
- (IBAction)editTable:(id)sender {
if(self.editing) {
[super setEditing:NO animated:NO];
[self.tableView setEditing:NO animated:NO];
[self.tableView reloadData];
[self.navigationItem.rightBarButtonItem setTitle:@"Edit"];
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStylePlain];
} else {
[super setEditing:YES animated:YES];
[self.tableView setEditing:YES animated:YES];
[self.tableView reloadData];
[self.navigationItem.rightBarButtonItem setTitle:@"Done"];
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
}
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyleforRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"HIT THIS BABY");
NSUInteger row = [indexPath row];
[accountsArray removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
Upvotes: 1
Views: 4371
Reputation: 1031
I just ran this together:
editingStyleforRowAtIndexPath
It should have been,
editingStyle forRowAtIndexPath
Upvotes: 1