Skip to content

Instantly share code, notes, and snippets.

@codedeman
Created July 27, 2019 09:19
Show Gist options
  • Save codedeman/b84d9877533aa484fa4d9ae7d02630ea to your computer and use it in GitHub Desktop.
Save codedeman/b84d9877533aa484fa4d9ae7d02630ea to your computer and use it in GitHub Desktop.
loadImagefromurl
func loadImage(urlString1:String,urlString2:String) {
DispatchQueue.global().async {
let url1 = URL(string: urlString1)
let url2 = URL(string: urlString2)
guard let data1 = try? Data(contentsOf: url1!) else {return}
guard let data2 = try? Data(contentsOf: url2!) else {return}
self.dispatchGroup.enter()
self.run {
self.imageURL1.image = UIImage(data: data1)
self.imageUrl2.image = UIImage(data: data2)
self.dispatchGroup.leave()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment