title: Multithreaded Core Data - NSManagedObject invalidated
body: <p>As the title suggests im working with a Core Data Application which gets filled with objects in different background threads (XML Parsing)</p>
  
  <p>In my background thread I'm doing this </p>
  
  <pre><code>managedContext = [[NSManagedObjectContext alloc] init];
  [managedContext setUndoManager:nil];
  
  [managedContext setPersistentStoreCoordinator: [[DataManager sharedManager] persistentStoreCoordinator]];
  
   NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 
   [nc addObserver:self
          selector:@selector(mergeChanges:)
              name:NSManagedObjectContextDidSaveNotification
            object:managedContext];
  
  
  NSMutableArray *returnSource = [[self parseDocument:doc] retain];
  
  
   [managedContext save:&amp;error];
  
   if (error) {
       NSLog(@"saving error in datafeed"); 
   }
  
   [managedContext reset];
  
  [self performSelectorOnMainThread:@selector(parseCompleteWithSource:) withObject:returnSource waitUntilDone:YES];
  </code></pre>
  
  <p>The Merge method looks like this:</p>
  
  <pre><code>NSManagedObjectContext *mainContext = [[DataManager sharedManager] managedObjectContext];
  
  // Merge changes into the main context on the main thread
  [mainContext performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:)
                                withObject:notification
                             waitUntilDone:YES];  
  
  [[NSNotificationCenter defaultCenter] removeObserver:self];
  </code></pre>
  
  <p>I think the merge is successful but as i want to display it in an UITableView it always tells me that my objects are invalidated which is to be expected because of </p>
  
  <pre><code>[managedContext reset];
  </code></pre>
  
  <p>What i want to do is show the Items which are currently in the database, in the background parse the xml and if thats finished i want to update the UITableView with the new / updated objects. How would I do that, can i "update" the objects to the other Context somehow or is the merge not working correctly?</p>
  
  <p>Do I need to define something specific in the Main ObjectContext?
  I've tried different mergepolicies without any luck.</p>
  
  <p>Hope you can help me, thanks! </p>