Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Last active May 11, 2017 12:08
Show Gist options
  • Save chriswebb09/6b9172ee6eff0bf83d9b39778117c60d to your computer and use it in GitHub Desktop.
Save chriswebb09/6b9172ee6eff0bf83d9b39778117c60d to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
let imageViewOne = UIImageView()
override func viewDidLoad() {
super.viewDidLoad()
imageViewOne.frame = UIScreen.main.bounds
view.addSubview(imageViewOne)
setImage()
}
}
extension ViewController: ImageDownloadProtocol {
func setImage() {
let url = URL(string: "http://cdn-www.dailypuppy.com/dog-images/colby-the-golden-retriever_77539_2016-09-16_w450.jpg")!
downloadImage(from: url) { image in
if Thread.isMainThread {
print("Thread is main")
}
self.imageViewOne.image = image
print("Done")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment