title: NSInternalInconsistencyException (invalid number of rows)
body: <p>Whenever I have data in my <code>UITableView</code> and I start deleting, it works fine.  However, when I get to the last object in the table, and delete it, it crashes.  </p>
  
  <p><code>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'</code></p>
  
  <p>Here's how I'm doing the editing stuff:    </p>
  
  <pre><code>-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
      if (editingStyle == UITableViewCellEditingStyleDelete) {
          // Delete the row from the data source
          if ([myData count] &gt;= 1) {
              [tableView beginUpdates];
              [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
              [myData removeObjectAtIndex:[indexPath row]];
  
              NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
              NSString *documentsDirectory = [paths objectAtIndex:0];
              NSString *somepath = [documentsDirectory stringByAppendingPathComponent:@"something.plist"];
              [myData writeToFile:somepath atomically:YES];
              [table reloadData];
              if ([myData count] == 0) {
                  [tableView endUpdates];
                  [tableView reloadData];
              }
              else {
              [tableView endUpdates];
              }
          }
      }   
  }
  </code></pre>
  
  <p>And also this:</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      // Return the number of rows in the section.
      if ([myData count] != 0) {
          return [myData count];
      }
      else {
          return 1;
      }
  }
  </code></pre>
  
  <p>The reason I'm returning 1 is because I'm making a cell that says "No data saved" in <code>cellForRowAtIndexPath</code>.  Here's what I mean:</p>
  
  <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
      }    
      if ([cityData count] != 0) {
          //normal setup removed for clarity
      }
      else {
          cell.textLabel.text = @"No saved data!";
      cell.textLabel.font = [UIFont boldSystemFontOfSize:14]; 
      cell.textLabel.textAlignment = UITextAlignmentCenter;
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
          cell.tag = 1;
      return cell;
      }
  }
  </code></pre>
  
  <p>So, what am I doing wrong in my editing code to get this error?  Thanks!</p>