title: Alert before deleting UITableView cell - (UIAlertController) Swift or Objective-C
body: <p>I want to delete a Table View cell, but before that action happens I want to give the user an alertview. I got this:</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
      if (editingStyle == UITableViewCellEditingStyleDelete) {
          UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning"
                                                          message:@"Are you sure?"
                                                         delegate:self
                                                cancelButtonTitle:@"NO"
                                                otherButtonTitles:@"YES", nil];
          [alert show];
  
          [self.array removeObjectAtIndex:indexPath.row];//or something similar to this based on your data source array structure
          [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
      }
  }
  
  - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  {
      NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
      if([title isEqualToString:@"Nee"])
      {
          NSLog(@"Nothing to do here");
      }
      else if([title isEqualToString:@"Ja"])
      {
          NSLog(@"Delete the cell");
  
      }
  }
  </code></pre>
  
  <p>But now when I swipe to right on the cell and the delete button appears I got no AlertView. I only get the AlertView when I press on the delete button. When I press on the delete button the message appears but the cell is already been deleted. </p>
  
  <p>How to make this work? So there is an AlertView when I swipe.</p>