Swipe to delete

I looked, and I can’t find anyone where the one on the stack is overflowing who had the same problem as me. Therefore, I use the following code:

  -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete); 
}

and when I press the delete button, it appears, but when I click it does nothing, what did I forget to do?

+5
source share
1 answer

In fact, you should delete your data after the instruction if. Currently your statement ifdoes nothing, because after it it has only a colon.

 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        //Code to delete data goes here.
        //This could include removing an object from an array, deleting it from core data,
        //and removing the selected row.
    }
}
+10
source

All Articles