Skip to content

Instantly share code, notes, and snippets.

@an-indya
Created May 13, 2018 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save an-indya/c5b57e670e752385802bce976239d2ba to your computer and use it in GitHub Desktop.
Save an-indya/c5b57e670e752385802bce976239d2ba to your computer and use it in GitHub Desktop.
NSString *imageUrl = @"http://images.apple.com/v/watch/c/images/nav_sport_large.jpg";
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil ];
NSURLSessionTask *downloadTask = [session downloadTaskWithURL:[NSURL URLWithString:imageUrl] completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
UIImage *downloadedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:location]];
dispatch_async(dispatch_get_main_queue(), ^{
self.imageView.image = downloadedImage;
});
}];
[downloadTask resume];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment