title: Asynchronous json request Objective C
body: <p>I am developing my first iPhone app and I am making a call to an API to return some JSON which populates different elements of my UI. Currently I have implemented a synchronous method in a helper class which I call in the viewDidLoad method.</p>
  
  <pre><code>-(NSDictionary*) dataRequest: (NSString*)url withMethod:(NSString*)method
  {
  
  NSError *e;
  NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
  [request setURL:[NSURL URLWithString:url]];
  [request setHTTPMethod:method];
  NSURLResponse *requestResponse;
  NSData *requestHandler = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;requestResponse error:nil];
  NSDictionary *json = [NSJSONSerialization JSONObjectWithData: requestHandler options: NSJSONReadingMutableContainers error: &amp;e];
  return json;
  
  }
  </code></pre>
  
  <p>The problem here is I lock up my UI, I tried to implement this asynchronously but the data gets returned long after the code attempts to populate the UI elements what is the best and correct way to implement asynchronous calls and populate my UI elements with the correct data?</p>