title: AFNetworking alternative to sendSynchronousRequest for populating CoreData
body: <p>I'm currently doing this when populating core data from a JSON file:</p>
  
  <pre><code>NSString *urlString = [value objectForKey:@"url"];
  NSURL *url = [NSURL URLWithString:urlString];
  NSURLRequest *request = [NSURLRequest requestWithURL:url];
  NSURLResponse *response = nil;
  NSError *error = nil;
  NSData *dataResponse = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  [managedObject setValue:dataResponse forKey:@"image"];
  </code></pre>
  
  <p>Is there a better (asynchronous) way to do this with AFNetworking? What is the best method for this case? Does it have to be synchronous because we're dealing with CoreData?</p>
  
  <p>UPDATE: Trying this now:</p>
  
  <pre><code>NSOperationQueue *queue = [[NSOperationQueue alloc] init];
  
  [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
                   {
                       [managedObject setValue:data forKey:@"image"];
                   }];
  </code></pre>
  
  <p>For some reason when I access the managed object later, the image attribute is always null, even though *data above is not null in the completion handler. The image gets saved fine in the synchronous method. What am I missing?</p>