Last active
May 11, 2017 12:08
-
-
Save chriswebb09/6b9172ee6eff0bf83d9b39778117c60d 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 { | |
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