title: NSFetchedResultsController duplicated rows
body: <p>I'm experiencing a weird behavior when using a secondary thread to refresh NSFetchedResultsController contents and I'd like to know it this is a common issue or I might be doing something wrong.</p>
  
  <p>I've got a centralized NSManagedObjectContext residing in my main delegate object which is used and shared by all view controllers. After loading a table by executing a fetch and calling its delegate method, a secondary thread is launched in background to update its results. However, and only in strange occasions, when inserting new entries they get duplicated in the table view. If I exit and reenter, duplicated rows disappear, what makes think they've only have existed in the managed object context.</p>
  
  <p>These are the followed steps:</p>
  
  <ol>
  <li>A background NSOperation thread creates a confined context linked to the same persistent store of the main application delegate. </li>
  <li>The new thread starts listening NSManagedObjectContextDidSaveNotification notifications.</li>
  <li>New rows are deleted, updated or inserted into the secondary context making always a save call when reaching some batch size.</li>
  <li><p>When saving in the background, the notification method calls the centralized context mergeChangesFromContextDidSaveNotification selector on the main thread as follow.</p>
  
  <pre><code>-(void)mergeChanges:(NSNotification *)notification
  {
      NSManagedObjectContext *mainContext = [[appDelegate sharedDelegate] managedObjectContext];
  
      [mainContext performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:) 
                                    withObject:notification 
                                 waitUntilDone:NO];
  }
  </code></pre></li>
  <li><p>After finishing the operation the listener is removed and the secondary context released.</p></li>
  </ol>
  
  <p>Does anybody have idea what is the reason is causing my table view rows to get duplicated, and how it can be solved?</p>
  
  <p>Thanks in advance for your help.</p>