title: NSFetchedResultsController returning incorrect section info
body: <p>I'm developing a simple database app that uses core data. Records are displayed in a tableView. To achieve this I make use of a NSFetchedResultsController.</p>
  
  <p>Everything works fine, including deleting, updating etc. The problem arises when I change some code that is clearly not related to my database structure and then run the app again. After that, the tableView (sometimes, not always) stays empty. </p>
  
  <p>What I found out is that the 'numberOfRowsInSection' method returns the incorrect number of objects (0). To get the number of rows in this method I use this code:</p>
  
  <pre><code>id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[self.fetchedResultsController sections]   objectAtIndex:section];
  return [sectionInfo numberOfObjects];
  </code></pre>
  
  <p>However, when I log the result of: </p>
  
  <pre><code>[self.fetchedResultsController.fetchedObjects count];
  </code></pre>
  
  <p>then, the correct amount of objects is shown.</p>
  
  <p>Ergo: the NSFetchedResultsController seems to give me the incorrect sectionInfo. It somehow thinks that section 0 holds 0 objects, while it holds (for example) 7 objects. </p>
  
  <p>Again: the code I change before running the app again, is not related to core data or the fetchedresultscontroller. For example, when I change a font and run the app again, the problem might arise. </p>
  
  <p>Has anyone an idea about where / how to fix this bug?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This is how I perform the fetch:</p>
  
  <pre><code>-(NSFetchedResultsController *)fetchedResultsController{
  
  NSManagedObjectContext *context = [self managedObjectContext];
  
  if (_fetchedResultsController != nil){
      return _fetchedResultsController;
  }
  
  NSFetchRequest *fetchrequest = [[NSFetchRequest alloc]init];
  NSEntityDescription *entitiy = [NSEntityDescription entityForName:@"JvBTimeRecords" inManagedObjectContext:context];
  [fetchrequest setEntity:entitiy];
  
  //sort descriptors
  NSSortDescriptor *sort = [[NSSortDescriptor alloc]initWithKey:@"date" ascending:NO];
  [fetchrequest setSortDescriptors:[NSArray arrayWithObject:sort]];
  
  NSPredicate *pred = [NSPredicate predicateWithFormat:@"(project.projectName = %@)", self.searchstring];
  [fetchrequest setPredicate:pred];
  
  //fetch only subset. Automatically fetch more as we scroll.
  [fetchrequest setFetchBatchSize:20];
  
  _fetchedResultsController = [[NSFetchedResultsController alloc]initWithFetchRequest:fetchrequest managedObjectContext:context sectionNameKeyPath:nil cacheName:@"CacheA"];
  _fetchedResultsController.delegate = self;
  
  
  return _fetchedResultsController;    
  }
  </code></pre>
  
  <p>In ViewDidLoad:</p>
  
  <pre><code>NSError *error;
  if (![[self fetchedResultsController]performFetch:&amp;error]) {
      /*
       Replace this implementation with code to handle the error appropriately.
  
       abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
       */
  
      NSLog(@"unresolved error %@, %@", error, [error userInfo]);
      //exit(-1); //fail
      abort();
  }
  </code></pre>