title: How to update a NSFetchedResultsController?
body: <p>I'm building an iOS app using RestKit and NSFetchedResultsController in my ViewControllers like explained in the following tutorial : <a href="http://www.alexedge.co.uk/blog/2013/03/08/introduction-restkit-0-20" rel="nofollow">http://www.alexedge.co.uk/blog/2013/03/08/introduction-restkit-0-20</a></p>
  
  <p>I have a subclass of a UITableViewController that displays the data fetched by the NSFetchedResultsController and it works well.</p>
  
  <p>Now I want to filter the displayed data so I'm adding a predicate to the fetch request of the NSFetchedResultsController and performing the fetch again (I don't use any cache) :</p>
  
  <pre><code>[self.fetchedResultsController.fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"title like 'some text'"]];
  NSError *error = nil;
  
  [self.fetchedResultsController performFetch:&amp;error];
  
  NSAssert(!error, @"Error performing fetch request: %@", error);
  </code></pre>
  
  <p>No error happens but the table view is not updated. I was expecting this method to be called</p>
  
  <pre><code>- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller;
  </code></pre>
  
  <p>but it's not...</p>
  
  <p>Worse, when I log the number of fetched objects like this</p>
  
  <pre><code>NSLog(@"before refetch : %d objects", self.fetchedResultsController.fetchedObjects.count);
  
  [...]
  
  NSLog(@"after refetch : %d objects", self.fetchedResultsController.fetchedObjects.count);
  </code></pre>
  
  <p>I'm getting</p>
  
  <pre><code>before refetch : 18 objects
  after refetch : 0 objects
  </code></pre>
  
  <p>(That's probably why my app crashes as soon as I try to scroll the table view)</p>
  
  <p>So how should I refresh the content of the NSFetchedResultsController so that controllerDidChangeContent is called and thus I can reload the table view ? and also that fetchedObjects contains something...</p>
  
  <p>EDIT:
  If at this moment I call the RestKit object manager to get the data displayed in the table view AND a Internet connection is available THEN the NSFetchedResultsController gets updated and the table view as well with the correct result of the fetch request WITH the predicate.</p>
  
  <p>EDIT:
  The predicate I use is the cause of the problem (I think). My entity has a transformable attribute which is parsed from an JSON array of strings and the predicate test if a search string exists in that array:</p>
  
  <pre><code>[NSPredicate predicateWithFormat:@"ANY transformable_attribute like 'search string'"]
  </code></pre>
  
  <p>The weird thing is that if I load the results without predicate and add it afterwards then I get 0 object BUT if I load the results directly with the predicate then I get 3 objects.
  Is my predicate wrong? </p>
  
  <p>EDIT: yes it is! Looks like we can't predicate on transformable attributes. I don't know why it works the first time.</p>