//enable swipe-to-delete
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
[items removeObjectAtIndex:indexPath.row];
//delete the corresponding row from the table view
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
}
When the commitEditingStyle method is present (it comes from the table view data source), the table view will automatically enable the swipe-to-delete.
All we have to do is remove the item from our data model and delete the corresponding row from our table view.