title: Core Data not changing until App restart
body: <p>I have a Core Data model which works well importing and exporting data. The way my app works is that it downloads a JSON file from the database, parses it, flushes out the core data model, then adds the data again (effectively a refresh of the local data model).</p>
  
  <p>If I make a change to the database, the change is reflected in the JSON file, but is not reflected in the core data model until I restart (aka end the app, open again) the app.</p>
  
  <p>Im sure it must be something to do with the way I am flushing out the database, but I just can't put my finger on it. I've included some code below to help.</p>
  
  <p><strong>The method I'm using to flush out the data model:</strong></p>
  
  <pre><code>- (void)resetCoreData;
  {    
      NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"AppWithCoreData.sqlite"];
  
      NSFileManager *fileManager = [NSFileManager defaultManager];
  
      [fileManager removeItemAtURL:storeURL error:NULL];
  
      NSError* error = nil;
  
      if([fileManager fileExistsAtPath:[NSString stringWithContentsOfURL:storeURL encoding:NSASCIIStringEncoding error:&amp;error]])
      {
          [fileManager removeItemAtURL:storeURL error:nil];
      }
  
      persistentStoreCoordinator = nil;
      managedObjectContext = nil;
  
      [self managedObjectContext]; // Rebuild Object Context    
  }
  </code></pre>
  
  <p><strong>One line of the code I'm using to add the data to the data model:</strong></p>
  
  <pre><code>[model setValue:[dictionary objectForKey:@"eventID"] forKey:@"eventID"];
  </code></pre>