I'm working on an application that uses core data, and I wanted to add a gesture if the user swipes to the left it will delete the object in the database. I have the gesture recognizer parts all set up, I'm having trouble creating the method to remove the object from the tableview and core data. So if anyone could look at this and point me into the right direction I would appreciate it! Thanks!
TableView.M
-(void)swipeleft:(UISwipeGestureRecognizer*)gestureRecognizer
{
NSIndexPath *indexPath = [[self tableView] indexPathForSelectedRow];
NSManagedObjectContext *context = [self managedObjectContext];
// Delete object from database
[context deleteObject:[self.lists objectAtIndex:indexPath.row]];
// Remove list from table view
[self.lists removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
@end
Error:
self(ViewController *) 0x8ea0a90
indexPath=(NSIndexPath * ) nil
context+(NSManagedObjectContext *) 0x8d747f0