Created
September 3, 2019 16:01
-
-
Save ShawonAshraf/c19ac354f71e0f3b51e3c555ea86c3f9 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
| func setImage(from url: String) { | |
| guard let imageURL = URL(string: url) else { return } | |
| // just not to cause a deadlock in UI! | |
| DispatchQueue.global().async { | |
| guard let imageData = try? Data(contentsOf: imageURL) else { return } | |
| let image = UIImage(data: imageData) | |
| DispatchQueue.main.async { | |
| self.imageView.image = image | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment