title: Delete Multiple Rows from UITableView
body: <p>I currently have 2 methods to delete rows from a UITableView, the first one is the standard slide then press delete, the second deletes all rows that are checked. The only problem is when you select more then 1 or 2 it crashes with the following in the NSLog</p>
  
  <pre><code>2014-04-08 22:37:53.985 PunchSlip[13128:60b] &lt;NSIndexPath: 0xc000000000038016&gt; {length = 2, path 
  
  = 0 - 7}
  2014-04-08 22:37:53.987 PunchSlip[13128:60b] 7
  2014-04-08 22:37:53.990 PunchSlip[13128:60b] &lt;NSIndexPath: 0xc000000000030016&gt; {length = 2, path = 0 - 6}
  2014-04-08 22:37:53.991 PunchSlip[13128:60b] 6
  2014-04-08 22:37:53.993 PunchSlip[13128:60b] &lt;NSIndexPath: 0xc000000000028016&gt; {length = 2, path = 0 - 5}
  2014-04-08 22:37:53.995 PunchSlip[13128:60b] 5
  2014-04-08 22:37:53.997 PunchSlip[13128:60b] &lt;NSIndexPath: 0xc000000000018016&gt; {length = 2, path = 0 - 3}
  2014-04-08 22:37:53.999 PunchSlip[13128:60b] 3
  2014-04-08 22:37:54.001 PunchSlip[13128:60b] &lt;NSIndexPath: 0xc000000000020016&gt; {length = 2, path = 0 - 4}
  2014-04-08 22:37:54.003 PunchSlip[13128:60b] 4
  2014-04-08 22:37:54.005 PunchSlip[13128:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray removeObjectAtIndex:]: index (4) beyond bounds (4)'
  </code></pre>
  
  <p>My first delete method looks like this:</p>
  
  <pre><code>-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
      if(editingStyle == UITableViewCellEditingStyleDelete) {
  
          //delete row from array and from plist
  
          [arrayFromPlist removeObjectAtIndex:indexPath.row];
  
  
          NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
          NSString *documentsDirectory = [paths objectAtIndex:0];
          NSString *plistLocation = [documentsDirectory stringByAppendingPathComponent:@"break.plist"];
          [arrayFromPlist writeToFile:plistLocation atomically:YES];
  
          [self.tableeView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
          //[self.tableeView reloadData];
  
      }
  }
  </code></pre>
  
  <p>My Second Method, which i based off off the first looks like this :</p>
  
  <pre><code>-(IBAction)erase:(id)sender{
      NSArray *selectedCells = [self.tableeView indexPathsForSelectedRows];
      for (NSString *string in selectedCells) {
          NSLog(@"%@", string);
          NSString *stringOne = [NSString stringWithFormat:@"%@", string];
  
          NSString *thisOne = [[stringOne componentsSeparatedByString:@" "] objectAtIndex:9];
          NSString *thatOne = [[thisOne componentsSeparatedByString:@"}"] objectAtIndex:0];
          int rowInt = [thatOne intValue];
          NSLog(@"%d", rowInt);
  
  
          [arrayFromPlist removeObjectAtIndex:rowInt];
  
  
         // [tableeView deleteRowsAtIndexPaths:[NSArray arrayWithObject:string] withRowAnimation:UITableViewRowAnimationAutomatic];
  
          [tableeView reloadData];
  
  
      }
  
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *plistLocation = [documentsDirectory stringByAppendingPathComponent:@"break.plist"];
      [arrayFromPlist writeToFile:plistLocation atomically:YES];
      [self viewDidLoad];
  
  
  }
  </code></pre>
  
  <p>The second method knows which cells are selected as you can see in the log, but when you do "too many" in this case 4 it says there is an NSRangeExeption. </p>
  
  <p>Any Ideas on how to correct it?</p>