title: Animating Row Deletion in UITableView with CoreData gives Assertion failure
body: <p>I have a UITableView that shows a list of objects stored with CoreData. I can delete an object using the following code:</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  if (editingStyle == UITableViewCellEditingStyleDelete) {
      NSLog(@"Delete row");
      [managedObjectContext deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];
  
      // Save the context.
      NSError *error;
      if (![managedObjectContext save:&amp;error]) {
          /*do this gracefully one day */
          NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
          abort();
      }
      [self refreshTables]; //where refreshTables just reloads the data the table is using and calls [self.tableView reloadData];
  }
  
  }
  </code></pre>
  
  <p>But it has no animation or aesthetic. </p>
  
  <p>When I try to animate by replacing </p>
  
  <pre><code>[self refreshTables]; 
  </code></pre>
  
  <p>with </p>
  
  <pre><code>[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>Assertion failure in -[UITableView _endCellAnimationsWithContext:], >/SourceCache/UIKit_Sim/UIKit-1261.5/UITableView.m:920
    2010-10-30 16:46:35.717 MyApp[38226:207] <em>*</em> 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 (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'</p>
  </blockquote>
  
  <p>I've tried having the <em>deleteRowsAtIndexPaths</em> code in a variety of places in the commitEditingStyle code with no luck (for example before removing the object from the mOC) but I can't seem to get around this error. </p>
  
  <p>I know Apple's iPhoneCoreDataRecipes example handles the problem by setting up a delegate for the FetchedResultsController to handle editing / deleting rows, but at this stage in development, if possible, I just want a simple solution for animating those deleted objects.</p>
  
  <p>How can I animate the removal of a row, before/after I remove the object from my managedObjectContext? </p>
  
  <p>EDIT: I've tried having deleteRowsAtIndexPaths before and after removing the item from the mOC, with the same error. </p>