Skip to content

Instantly share code, notes, and snippets.

@helloworldsmart
Created June 9, 2017 02:26
Show Gist options
  • Select an option

  • Save helloworldsmart/0379fb9968ed44a5eb2fe6b518c1c604 to your computer and use it in GitHub Desktop.

Select an option

Save helloworldsmart/0379fb9968ed44a5eb2fe6b518c1c604 to your computer and use it in GitHub Desktop.
func withBigImage(completionHandler handler: @escaping (_ image: UIImage) -> Void) {
DispatchQueue.global(qos: .userInitiated).async { () -> Void in
if let url = URL(string: BigImages.whale.rawValue),
let imgData = try? Data(contentsOf: url),
let img = UIImage(data: imgData) {
DispatchQueue.main.async(execute: { () -> Void in
handler(img)
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment