title: objectivec NSURLSessionDownloadTask
body: <p>I viewed this code here,</p>
  
  <p><a href="https://www.raywenderlich.com/67081/cookbook-using-nsurlsession" rel="nofollow">https://www.raywenderlich.com/67081/cookbook-using-nsurlsession</a></p>
  
  <pre><code>NSURLSessionDownloadTask *downloadPhotoTask = [[NSURLSession sharedSession]
  downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
  UIImage *downloadedImage = [UIImage imageWithData:
  [NSData dataWithContentsOfURL:location]];
  }];
  </code></pre>
  
  <p>I hope this code connects to the server two times, so the images are loading slow. I just want to know how to use NSURLSessionDownloadTask to download image by hitting the server only once. </p>