title: RestKit sync service, advice with temporary objects - How
body: <p>I'm making some app and I want to provide offline functionality to it.
  Problem is with getting new data from backend as temporary objects not saved in persistent store. Why I want this? Because I want to check whether data from backend is newer than offline one (by update date) If yes then update, otherwise, send it to the backend.</p>
  
  <p>For now I'm trying something like this: </p>
  
  <pre><code>NSMutableURLRequest *apiEmailRequest = [[RKObjectManager sharedManager] requestWithObject:@"ApiEmail" method:RKRequestMethodGET path:pathToContent parameters:nil];
  
  RKObjectRequestOperation *apiEmailOperation = [[RKObjectManager sharedManager] managedObjectRequestOperationWithRequest:apiEmailRequest managedObjectContext:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
  
  *********************CHECK FOR BACKEND EMAILS AND OFFLINE ONE ********************** 
  NSArray *backendEmails = [mappingResult array];
  
  
      for (ApiEmail *backendEmail in backendEmails) {
          if ([backendEmail isKindOfClass:[ApiEmail class]]) {
              NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"ApiEmail"];
              NSPredicate *filterByApplication = [NSPredicate
                                                  predicateWithFormat:@"emailId == %@", backendEmail.emailId];
              [fetchRequest setPredicate:filterByApplication];
  
              NSArray *persistentEmails = [[RKManagedObjectStore defaultStore].persistentStoreManagedObjectContext executeFetchRequest:fetchRequest error:nil];
  
              *HERE PUT IT INTO mainQueueManagedObjectContext and 
              saveToPersistentStore else POST it to the backend*    
          }
      }
  
  } failure:^(RKObjectRequestOperation *operation, NSError *error) {
      *ERROR*
  }];
  
  
  return apiEmailOperation;
  
  [[RKObjectManager sharedManager] enqueueObjectRequestOperation:apiEmailOperation];
  </code></pre>
  
  <p>Is there any way to do it without creating new RKObjectManager?</p>
  
  <p>Best regards, Adrian.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>-(void)willSave {
  [super willSave];
  NSDictionary *remoteCommits = [NSDictionary dictionaryWithDictionary:[self committedValuesForKeys:@[@"updateDate"]]];
  
  NSDate *updateDate = [remoteCommits valueForKey:@"updateDate"];
  
  NSComparisonResult result = [self.updateDate compare:updateDate];
  
  if(result == NSOrderedDescending) {
      [self.managedObjectContext refreshObject:self mergeChanges:NO];
  } else {
      [self.managedObjectContext refreshObject:self mergeChanges:YES];
  }
  }
  </code></pre>
  
  <p>After such modification I'm getting <em>Failed to process pending changes before save.  The context is still dirty after 1000 attempts.</em> </p>