title: Crash when deleting row - Inconsistency in section not being updated
body: <p>When I delete a row from UITableView using commitEditingStyle, my app crashes with the following error message. The odd thing though is I am deleting from section 3. The inconsistency according to the message is from section 4. </p>
  
  <blockquote>
    <p><strong>* Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UITableView.m:920
    2010-11-22 19:56:44.789 bCab[23049:207] *</strong> Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 4.  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 (0), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted).'</p>
  </blockquote>
  
  <p>In datasource, I update section 4 depending on the number of rows in section 3. When a row is deleted from section 3, number of rows in section 4 goes from 0 to 1. This seems to cause the issue. Is there no way to avoid this? </p>
  
  <p>Any pointers would be highly appreciated. 
  Thanks.</p>
  
  <p><strong>UPDATE</strong>:  </p>
  
  <p><strong>numberOfSectionsInTableView</strong>
      - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
          return 6;<br>
      }</p>
  
  <p><strong>numberOfRowsInSection</strong></p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  bCabAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
  
      if (section == 0) {        // First name, last name
          return 2;
      }
      else if (section == 1) {   // Password
          return 2;   
      }
      else if (section == 2) {   // Mobile, DOB , Gender
          return 3;
      }
      else if (section == 3) {    // credit cards
          return [creditCards count]; 
      }
      else if (section == 4) {    // Add credit card 
          if ([creditCards count] &gt;= 3) {
              return 0;   
          }
          else {
              return 1;   
          }
      }
      else if (section == 5) {
          return 0;   
      }
  
      return 0;
  </code></pre>
  
  <p>}</p>
  
  <p><strong>commitEditingStyle</strong></p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
      if (editingStyle == UITableViewCellEditingStyleDelete) {
          if (indexPath.section == 3) {
          // Delete the row from the data source  
          NSLog(@"%d %d", indexPath.section, indexPath.row);
          [creditCards removeObjectAtIndex:indexPath.row];
  
          // Delete from backend
  
          [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  
          //[tableView reloadData];
          }
      }   
      else if (editingStyle == UITableViewCellEditingStyleInsert) {
          // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
      }  
  </code></pre>
  
  <p>}</p>
  
  <p>I have tried with and without [tableView reloadData] with same results.</p>
  
  <p>Thanks for trying to help!</p>