Skip to content

Instantly share code, notes, and snippets.

@olbrichj
Last active March 21, 2018 10:38
Show Gist options
  • Save olbrichj/ba6d8e5b8f966db3295f5e2cc4057c58 to your computer and use it in GitHub Desktop.
Save olbrichj/ba6d8e5b8f966db3295f5e2cc4057c58 to your computer and use it in GitHub Desktop.
URLSession.shared.dataTask(with: backendurl!) { data, _, error in
if error != nil {
print(error)
return
}
let imageurl = String(data: data!, encoding: String.Encoding.utf8) as String! // For simplicity response is only the URL
URLSession.shared.dataTask(with: URL(string:imageurl!)!) { (data, response, error) in
if error != nil {
print(error)
return
}
DispatchQueue.main.async {
imageView.image = UIImage(data: data!)
}
}.resume()
}.resume()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment