title: iOS delete a tableview row
body: <p>I had my app working fine on iOS 6. With the upgrade I stopped being able to delete rows from my <code>UITableView</code>.</p>
  
  <p>I've a button in my prototype cell.</p>
  
  <p><strong>Here is the button's function:</strong></p>
  
  <pre><code>- (IBAction)deleteCell:(id)sender {
      UIButton *btn = (UIButton*) sender;
      UITableViewCell *cell = (UITableViewCell*) btn.superview.superview;
      NSIndexPath *indexPath = [_tableView indexPathForCell:cell];
      if([names count] &gt; 9) {
          int index = indexPath.row;
          [names removeObjectAtIndex:index];
          [photos removeObjectAtIndex:index];
          [_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
      } 
  } 
  </code></pre>
  
  <p>The problem is my index variable is always 0.</p>
  
  <p><strong>I tried another solution:</strong></p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  
          if (editingStyle == UITableViewCellEditingStyleDelete) {
              int index = indexPath.row;
              [names removeObjectAtIndex:index];
              [photos removeObjectAtIndex:index];
              [_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
  
  }
  }
  </code></pre>
  
  <p>This solution doesn't work either. Nothing happens when I swipe right.</p>