I'd like to be able to use a custom button on my custom UITableViewCell to delete the cell, not the standard swipe-to-delete. I already have the button on the cell, so I don't need help with that. I do need help with creating the action to delete the cell.
I've taken the code from editingStyle forRowAtIndexPath and put it into an IBAction but it doesn't work.
I get 2 "use of undeclared identifier indexPath" errors. Does anyone have any idea how to accomplish this? Thanks a bunch to anyone that can help out.
If it makes a difference, I'm using Core Data and NSFetchedResultsController
I've taken the code from editingStyle forRowAtIndexPath and put it into an IBAction but it doesn't work.
Code:
-(IBAction)deleteItem:(id)sender {
[self.tableView beginUpdates];
// Delete the item
Item *itemToDelete = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"Deleting (%@)", itemToDelete.name);
[self.managedObjectContext deleteObject:itemToDelete];
[self.managedObjectContext save:nil];
// Delete the row
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
[self performFetch];
[self.tableView endUpdates];
}
I get 2 "use of undeclared identifier indexPath" errors. Does anyone have any idea how to accomplish this? Thanks a bunch to anyone that can help out.
If it makes a difference, I'm using Core Data and NSFetchedResultsController