title: RestKit & Core Data - Reloading data in table view nested in a view container
body: <p>I'm working on a sync process where the latest changed objects are loaded from a server with RestKit using a timestamp and saving all changes using Core Data based on the MOC idea. </p>
  
  <p><strong>Sequence</strong><br>
  1) Starting the sync process and save changes to Core Data [AppDelegate]<br>
  2) Refetching data from Core Data after process is finished and reload data [ContactTableView]<br>
  3) Reloading input views when fetch is complete  [ContactDetailView]<br>
  4) Reloading table view placed in ViewContainer inside of ContactDetailView [ContactDetailTV]</p>
  
  <p><strong>Passing data between views</strong>  </p>
  
  <pre><code>ContactTableView (passing object when user selects row)
  --» ContactDetailView (passing object to subView in viewContainer)
      --» ContactDetailTV (displaying data of object in a tableView) 
  </code></pre>
  
  <p><strong>Problem</strong><br>
  <em>That works</em><br>
  When I'm inside of ContactTableView the table view is reloaded with the new fetched data and everything is fine.</p>
  
  <p><em>That doesn't work</em><br>
  When I'm inside of ContactDetailTV (because the data can change when I'm looking at it) the view displays the old data inside of the ContactDetailTV even after calling [self.tableView reloadData].</p>
  
  <p><strong>Question</strong><br>
  What am I doing wrong or what is missing to get the reloading to work like expected?</p>
  
  <hr>
  
  <p><em>Code</em></p>
  
  <p><strong>AppDelegate</strong></p>
  
  <pre><code>- (void)startSyncProcess:(NSInteger)operationCode
  {        
  // Init helper
  syncCount = 0;
  syncProcess = 0;
  
  switch (operationCode) 
  {
      default:
          // (1) Request deleted companys from server
          [self requestDeletedCompanysFromServer];
          break;
  
      case 0:
          // (2) Request deleted contacts from server
          [self requestDeletedContactsFromServer];
          break;
  
      case 1:
          // (2) Request edited companys from server
          [self requestEditedCompanysFromServer];
          break;
  
      case 2:
          // (2) Request edited contacts from server
          [self requestEditedContactsFromServer];
          break;
  
      case 3:
          // Reload data views
          [self saveCurrentSyncTime];            
  
          [[NSNotificationCenter defaultCenter] postNotificationName:@"updateTableViewAfterSave" object:self];
          break;
  }
  }
  </code></pre>
  
  <p><strong>ContactTableView</strong></p>
  
  <pre><code>- (void)syncContextDidSave:(NSNotification*)saveNotification 
  {   
     // Handling the "updateTableViewAfterSave"-notification by refetching the data with Core Data
      NSError *error;
      if (![[self fetchedResultsController] performFetch:&amp;error]) 
           NSLog(@"[ERROR] Saving failed with error: %@", [error userInfo]);
  
      [[NSNotificationCenter defaultCenter] postNotificationName:@"updateSubViewAfterSave" object:nil];
  }
  </code></pre>
  
  <p><strong>ContactDetailTV</strong></p>
  
  <pre><code>- (void)updateSubViewAfterSave:(NSNotification *)saveNotification
  {
      // Handling the "updateSubViewAfterSave"-notification by updating the table view that displays the data without using a fetchedResultsController
      [self.tableView reloadData];
  }
  </code></pre>