Downloading image from a URL on Swift

PHOTO EMBED

Sun Jan 12 2020 17:30:26 GMT+0000 (Coordinated Universal Time)

Saved by @19sunflower91 #ios #swift #swift4

let url = URL(string: image.url)
let data = try? Data(contentsOf: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
imageView.image = UIImage(data: data!)
content_copyCOPY

It's important to note that the Data(contentsOf:) method will download the contents of the url synchronously in the same thread the code is being executed, so do not invoke this in the main thread of your application.

https://stackoverflow.com/questions/24231680/loading-downloading-image-from-url-on-swift