title: Delete a cell row in Objective-C
body: <p>Want to delete a row when you swipe with your finger on the cell. </p>
  
  <p>I got this: </p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSLog(@"Delete");
  }
  </code></pre>
  
  <p>After running the Delete button appears but when I press on it nothing happens. What do I need to insert in to the brackets?</p>
  
  <p>And my .m</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  
      UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
      NSString *str = cell.textLabel.text;
  
      NSLog(@"U selected %@", str);
      [tableView deselectRowAtIndexPath:indexPath animated:YES];
  }
  
  - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  
      if (editingStyle == UITableViewCellEditingStyleDelete) {
          [self.dataSourceArray removeObjectAtIndex:indexPath.row];//or something similar to this based on your data source array structure
          //remove the corresponding object from your data source array before this or else you will get a crash
          [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
      }
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.array = @[@"test",@"test"];
  
      UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
      [refreshControl addTarget:nil action:@selector(updateArray) forControlEvents:UIControlEventValueChanged];
      self.refreshControl = refreshControl;
  }
  </code></pre>