title: NSManagedObjectContext merge from private context, refresh only changed objects
body: <p><strong>Facts:</strong></p>
  
  <ul>
  <li>I use CoreData.</li>
  <li>I have parent object with child rows, where children might well exceed 500 objects.</li>
  <li>I show those child objects in <code>UITableViewController</code> <code>UITableView</code>.</li>
  <li>I have set up it to work with <code>NSFetchedResultsController</code>, allowing me to get updates as soon as something changes. And I need that.</li>
  <li><p>I am merging changes from private context to main context with the following code:</p>
  
  <pre><code>@objc func privateContextDidSaveNotification(notification: NSNotification)
  {            
      let savedContext = notification.object as! NSManagedObjectContext
  
      if savedContext == self.managedObjectContext
      {
          return   // This is the Main context
      }
  
      if savedContext.persistentStoreCoordinator != self.managedObjectContext.persistentStoreCoordinator
      {
          return   // This is different DB
      }
  
      self.managedObjectContext.performBlockAndWait(
      {
          self.managedObjectContext.mergeChangesFromContextDidSaveNotification(notification)
          self.managedObjectContext.refreshAllObjects()
      })
  }
  </code></pre></li>
  <li><code>NSFetchedResultsController.delegate</code> is set only on child objects.</li>
  </ul>
  
  <p><strong>Problem:</strong></p>
  
  <p>If even one child object for this parent object changes, the <code>
  func controller(controller: NSFetchedResultsController,
          didChangeObject anObject: AnyObject,
          atIndexPath indexPath: NSIndexPath?,
          forChangeType type: NSFetchedResultsChangeType,
          newIndexPath: NSIndexPath?)</code> gets called for all child rows, meaning, it's called >500 times, and basically, the app freezes.</p>
  
  <p><strong>What I Discovered:</strong></p>
  
  <ol>
  <li>The update notifications for all child objects is caused by this line after merge: <code>self.managedObjectContext.refreshAllObjects()</code>.</li>
  <li>If I remove that line, then <code>NSFetchedResultsController</code> doesn't receive any notification that something is updated at all - but I need that.</li>
  </ol>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li>How can I make  that one particular row of changed child object, meaning - how can I notify <code>NSFetchedResultsController</code> only actually changed rows?</li>
  <li>What's the typical solution to notify NSFetchedResultsController about merged objects?</li>
  </ol>
  
  <p>Thanks a lot!</p>
  
  <p>Maris</p>