Created
May 13, 2018 03:22
-
-
Save an-indya/c5b57e670e752385802bce976239d2ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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