title: Replacing Core Data sqlite file while app is running, data does not update
body: <p>I am developing a backup/restore system for my app in which the user can download a backed-up version of the core data store (sqlite file) and replace the currently-used data store with the downloaded file. However, once the user downloads the file and replaces the current data store, none of the data appears to have been updated. But when the app is quit &amp; re-launched, the restored data is available. How can I force my app to reload the core data store's file?</p>
  
  <p>I have tried to access the app delegate from my UIViewController which restores the data, like so, to rebuild the core data stack and propogate it across all view controllers in the navigation stack:</p>
  
  <pre><code>MyAppDelegate *app = [[UIApplication sharedApplication] delegate];
  app.managedObjectContext = nil;
  app.persistentStoreCoordinator = nil;
  app.managedObjectModel = nil;
  managedObjectContext = [app managedObjectContext];
  
  NSArray *controllers = [self.navigationController viewControllers];
  UIViewController *c;
  for (int i = 0; i &lt; [controllers count]; i++) {
      c = [controllers objectAtIndex:i];
      [c setManagedObjectContext:managedObjectContext];
  }
  </code></pre>
  
  <p>But this isn't working, it only throws the following error when I go back to the root view controller: <code>'The NSManagedObject with ID:0x5d79060 &lt;x-coredata://D8E73D64-C9BA-4CFA-9213-F8BD61749155/MyObject/p2&gt; has been invalidated.'</code></p>
  
  <p><strong>Does anyone know how to force the app to reload the data and begin working with the new data store file?</strong></p>