redribben

sessiondownload

Oct 26th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NSURLSessionDownloadTask *getImageTask = [session downloadTaskWithURL:[NSURL URLWithString:imageUrl]
  2.                                                     completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
  3.                                                         // Here you use the location variable provided in the completion handler to get a pointer to the image
  4.                                                         UIImage *downloadedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:location]];
  5.                                                         // Finally you could, for example, update UIImageView’s image to show the new file.
  6.                                                         dispatch_async(dispatch_get_main_queue(), ^{
  7.                                                             // do stuff with image
  8.                                                             _imageWithBlock.image = downloadedImage;
  9.                                                         });
  10.                                                     }];
Add Comment
Please, Sign In to add comment