Skip to content

Instantly share code, notes, and snippets.

@alexsanchezdev
Last active December 12, 2019 14:33
Show Gist options
  • Save alexsanchezdev/00d68edfcd2b6188620534191ed2d309 to your computer and use it in GitHub Desktop.
Save alexsanchezdev/00d68edfcd2b6188620534191ed2d309 to your computer and use it in GitHub Desktop.
URLSession download images example | Swift 3
if let image = imageURL {
let url = URL(string: image)
URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) in
if error != nil {
print(error!)
return
}
DispatchQueue.main.async {
imageView.image = UIImage(data: data!)
}
}).resume()
}
@kiritm-nimblechapps
Copy link

@guptshivu
Copy link

I am new in this.Can you please tell me how can you downloads 100 images asynchronously at a time using this?

@Aizaz-Abbasi
Copy link

how can we use this in collection view where is doesn't load all images some times repeat same image??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment