title: Rest Kit Persistance/Performance issue with Multiplie MOCs
body: <p>This is the first time i've used the new version of RestKit and multiple MOC so this ones got my a little stumped. Im using RestKit 0.20-pre5 and am adding Managed Objects through RestKit operations as well as manually throughout the application.</p>
  
  <p>RestKits provides two MOCs to manage performance: the mainQueue and PersistantStore Object contexts. From inspecting RestKits code all new managed objects are saved to the mainQueue MOC (Based on RKObjectManager line 433 and inspection of various pointer addresses). Objects created by RestKit get persisted fine (after calling a save of course) however whenever I create my own ManagedObjects in the same mainQueue MOC and save it, they do not persist when I relaunch the application. (I save the relevant MOC quite often)</p>
  
  <p>This is where the persistant store comes in. Whenever I save the persistant store along with the mainQueue MOC the data persists. I imagine this has something to do with the RKManagedObjectStore merging changes whenever I call save on the persistantStoreMOC (via a notification) So... everything good right?</p>
  
  <p>The problem is whenever I save both contexts there is a noticeable lag that lasts at least 1 second (it can vary up to 3!). This lag seems to increase the more NSManagedObjects I create. I have run instruments and there are no memory issues. I must be using RestKits implementation of core data incorrectly.</p>
  
  <p>For the record I am saving using the following method:</p>
  
  <pre><code>- (void)saveContext
  {
      __block BOOL _blockSuccess;
      __block NSError *_blockError;
  
      NSManagedObjectContext *persistantContext = [[[RKObjectManager sharedManager] managedObjectStore] persistentStoreManagedObjectContext];
  
      [globalManagedObjectContext performBlockAndWait:^{
              _blockSuccess = [globalManagedObjectContext save:&amp;_blockError];
      }];
      if (! _blockSuccess) NSLog(@"Failed to save context: %@", _blockError);
  
      [persistantContext performBlock:^{
          _blockSuccess = [persistantContext save:&amp;_blockError];
          if (! _blockSuccess) NSLog(@"Failed to save context: %@", _blockError);
      }];
  }
  </code></pre>
  
  <p>This is called from a singleton object whenever we want to save the state of the application. (globalManagedObjectContext is simply a macro pointing to RestKits mainQueueObjectContext). Removing the persistantContext save removes the lag but of course doesn't persist the data.</p>
  
  <p>Anyones help (especially Blake Watters ;) would be greatly appreciated!</p>
  
  <p>Cheers,</p>
  
  <p>Aron</p>