Created
August 8, 2018 14:40
-
-
Save J7mbo/95a18194fa4577583043d99c570ef60a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class ViewController: UIViewController | |
{ | |
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
async { | |
let jsonDownloader: JsonDownloader = JsonDownloader() | |
let imageDownloader: ImageDownloader = ImageDownloader() | |
let json: [String: AnyObject] = try! await(jsonDownloader.downloadContentsOfUrl("ourUrl.com")) | |
let image: UIImage = try! await(imageDownloader.downloadImage(json["image_url"])) | |
DispatchQueue.main.async { | |
let imageView = UIImageView(image: image) | |
imageView.frame = CGRect(x: 0, y: 0, width: 300, height: 300) | |
view.addSubview(imageView) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment