title: Fetch data using Post method in Objective-c
body: <p>I am fetching data using POST method. And I have successfully retrieved all the data.It's taking too long to display it in UI but I can print it immediately on console, my code is</p>
  
  <pre><code>NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
  [request setURL:[NSURL URLWithString:@"http://www.xxxyyy.com/v1/api/client/authorize"]];
  [request setHTTPMethod:@"POST"];
  [request setValue:@"ABCD" forHTTPHeaderField:@"Authkey"];
  [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  
   NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  
  [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) 
  {
      NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
  
      [request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Authkey"];
  
      NSData* data1 = [requestReply dataUsingEncoding:NSUTF8StringEncoding];
      jsonReturnArray = [NSJSONSerialization JSONObjectWithData:data1 options:NSJSONReadingAllowFragments error:&amp;error];
  
      NSArray *array = [jsonReturnArray copy];
      [self rec:array];
  
      NSString *phoneNumber=[NSString stringWithFormat:@"%@",[jsonReturnArray valueForKey:@"phone"]];
      lblPhoneNumber.text = phoneNumber;
  
      NSString *Address=[NSString stringWithFormat:@"%@ %@ %@,CA %@",[jsonReturnArray valueForKey:@"street1"],[jsonReturnArray valueForKey:@"street2"],[jsonReturnArray valueForKey:@"city"],[jsonReturnArray valueForKey:@"postalcode"]];
      lblAddress.text=Address;//takes long time to display
      NSLog(@"%@",Address);//immeaditely print
  
      strlatitude=[jsonReturnArray valueForKey:@"latitude"];
      strlongitude=[jsonReturnArray valueForKey:@"longitude"];
  
      [self Map:(MKMapView *)mapLocation didUpdateUserLocation:(MKUserLocation *)nil];//method call
  }] resume];
  </code></pre>