title: Core Data Serious Application Error at controllerDidChangeContent
body: <p>Hello I am stacked now with the error below.</p>
  
  <blockquote>
    <p>CoreData: error: Serious application error.<br>
    An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:.<br>
    Invalid update: invalid number of sections.<br>
    The number of sections contained in the table view after the update (7) must be equal to the number of sections contained in the table view before the update (6), 
    plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted). with userInfo (null)</p>
  </blockquote>
  
  <p>My application has multiple sections tableView.
  And error only occurs when I try to insert new section record.
  If the section already exists, error not occurred.</p>
  
  <p>The related code is following.</p>
  
  <pre><code>- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
  {
      [self.tableView beginUpdates];
  }
  
  - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
         atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
         newIndexPath:(NSIndexPath *)newIndexPath
  {
       UITableView *tableView = self.tableView;
       DLog(@"newIndexPath %@",newIndexPath);
      switch(type) {
          case NSFetchedResultsChangeInsert:
              [tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
              break;
  
          case NSFetchedResultsChangeDelete:
          [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
              break;
  
          case NSFetchedResultsChangeUpdate:
              [self configureCell:[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
              break;
  
          case NSFetchedResultsChangeMove:
              [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
              [tableView insertRowsAtIndexPaths:@[newIndexPath]withRowAnimation:UITableViewRowAnimationFade];
              break;
      }
  }
  
  - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
  {
      /*NSError *error = nil;
      if (![[self fetchedResultsController] performFetch:&amp;error]) {
          DLog(@"Unresolved error %@, %@", error, [error userInfo]);
          abort();
      }
      [self.tableView reloadData];*/
      [self.tableView endUpdates];
  }
  </code></pre>
  
  <p>Also I put sectionNameKeyPath at fetchResultsController. 
  year column does not exist in real core data, it is extension column.</p>
  
  <pre><code>    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"year" cacheName:@"Master"];
  </code></pre>