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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how can we use this in collection view where is doesn't load all images some times repeat same image??