Last active
December 12, 2019 14:33
-
-
Save alexsanchezdev/00d68edfcd2b6188620534191ed2d309 to your computer and use it in GitHub Desktop.
URLSession download images example | Swift 3
This file contains 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
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() | |
} |
it's nice and create extension like https://iosdevcenters.blogspot.com/2018/06/how-to-downloading-image-from-server.html
I am new in this.Can you please tell me how can you downloads 100 images asynchronously at a time using this?
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
@asselinka default cells don't have image views in it, you can only access "title" and "subtitle" if I remember right... You have to make a custom cell with an imageView inside and then refer it in your code... Could be that the problem?