title: Reload UITableView data every time context changes?
body: <p>I have a UITableViewController that's a subclass of <code>CoreDataTableViewController</code> (it's the <a href="https://stackoverflow.com/questions/10272911/ios-stanford-tutorial-coredatatableviewcontroller-licence">Stanford class</a>). That implements a <code>fetchedResultsController</code>. </p>
  
  <p>Now, in my <code>viewWillAppear</code>, I have this:</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated
  {
      [super viewWillAppear:animated];
  
      if(!self.managedObjectContext) {
          [self useManagedDocument];
      }
  }
  </code></pre>
  
  <p>It initializes the <code>managedObjectContext</code> if I don't have one, and gets it from a helper class. In the MOC setter, I initialize the <code>fetchedResultsController</code>:</p>
  
  <pre><code>- (void)setManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
  {
      _managedObjectContext = managedObjectContext;
  
      if(self.managedObjectContext) {
          NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:CD_ITEM_ENTITY_NAME];
          request.sortDescriptors = @[[NSSortDescriptor
                                       sortDescriptorWithKey:CD_ITEM_NAME_PROPERTY
                                       ascending:YES
                                       selector:@selector(localizedCaseInsensitiveCompare:)]];
          request.predicate = nil;
          self.fetchedResultsController = [[NSFetchedResultsController alloc]
                                           initWithFetchRequest:request
                                           managedObjectContext:self.managedObjectContext
                                           sectionNameKeyPath:nil
                                           cacheName:nil];
      } else {
          self.fetchedResultsController = nil;
      }
  
  }
  </code></pre>
  
  <p>When my program starts, it loads the table data up correctly and my debugger says there was a fetch request made. However, after inserting data into my Core Data graph, and saving, it says the context changes and fires this delegate method:</p>
  
  <pre><code>- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
  {
      /*NSError *error;
      [controller performFetch:&amp;error];
      if(error) {
          NSLog(@"%@", error);
      }
      [self.tableView reloadData];*/
  }
  </code></pre>
  
  <p>I commented this because it wasn't working. Basically, what I want to do is reload the data every time the context changes. If I add an item in another view controller and then go back to this one, it should reload in that case too.</p>
  
  <p>How do I implement this? I tried doing <code>performFetch</code> in that delegate method and it entered it (I checked by setting a breakpoint inside), but the <code>performFetch</code> did nothing and my table wasn't reloaded.</p>
  
  <p>When I add an item in a modal VC (another one I have for managing items) this is what happens in my logger:</p>
  
  <pre><code>2013-05-10 22:41:38.264 App1[7742:c07] [ItemCDTVC performFetch] fetching all Item (i.e., no predicate)
  2013-05-10 22:41:46.454 App1[7742:c07] NSManagedObjects did change.
  2013-05-10 22:41:46.456 App1[7742:c07] NSManagedContext did save.
  </code></pre>
  
  <p>When I close my app but do not quit it from the multitasking bar, and then reopen it, it does nothing. No fetch. Well, if the context didn't change I don't want it to fire a request, but imagine if the user adds an item in another ViewController and then goes back to my ItemCDTVC, which lists all items. Does it get a context changed notification so it can call the delegate method to update the table, or will I always have to refresh regardless of changes in my <code>viewWillAppear</code>? I currently have it set to do it only once, on app load.</p>