title: NSFetchedResultsController: don't refresh each new cell
body: <p>I've noticed that insertion of data with a <code>NSFetchedResultsController</code> in <code>Core Data</code> would refresh each cell in my <code>Table View</code> using the <code>tableView:cellForRowAtIndexPath:</code> method.</p>
  
  <p>My application starts by fetching 100+ items from a Web Service. When they are added to the Core Data Database, a <code>tableView:cellForRowAtIndexPath:</code> call is made for each cell. I expect only the first 8-9 visible cells to refresh. How can I change that? The reason why this is a problem is that my application is downloading the cover image first time the <code>tableView:cellForRowAtIndexPath</code> is called -- and when it is called for each cell, this is not a optimal solution.</p>
  
  <p><strong>EDIT1:</strong>
  My code is fully based on an example from the <a href="http://www.stanford.edu/class/cs193p/cgi-bin/drupal/" rel="nofollow">CS 192p course at Stanford University</a>. I've downloaded their <code>Photomania.zip</code> from lecture 14 and just inserted the <code>tableView:willDisplayCell:forRowAtIndexPath:</code> method which displays the items name in the log when the method is called. You can grab my code here: <a href="http://uploads.demaweb.dk/Photomania.zip" rel="nofollow">http://uploads.demaweb.dk/Photomania.zip</a>.
  As you will see, it looks like this method is called for each item in the table? Why?</p>
  
  <p><strong>EDIT2:</strong>
  I was using this method in my <code>NSFetchedResultsControllerDelegate</code> from the iOS Developer Library. I found out that the <code>withRowAnimation:UITableViewRowAnimationFade</code> cause it to both call the <code>cellForRowAtIndexPath</code> and <code>willDisplayCell</code> for each cell. When changing it to <code>withRowAnimation:UITableViewRowAnimationNone</code> only the visible cells are called.</p>
  
  <pre><code>- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id&lt;NSFetchedResultsSectionInfo&gt;)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
  
      switch(type) {
          case NSFetchedResultsChangeInsert:
              [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
              break;
  
          case NSFetchedResultsChangeDelete:
              [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
              break;
      }
  }
  </code></pre>