Skip to content

Instantly share code, notes, and snippets.

@toast38coza
Created October 19, 2014 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toast38coza/f3f2409ec86516e6c985 to your computer and use it in GitHub Desktop.
Save toast38coza/f3f2409ec86516e6c985 to your computer and use it in GitHub Desktop.
Fetch an image from the web
let url = NSURL(string: "http://www.haskell.org/happy/Happy.gif")
let urlRequest = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(urlRequest, queue: NSOperationQueue.mainQueue(),
completionHandler: {
response, data, error in
if error != nil {
println("There was an error")
} else {
let image = UIImage(data: data)
self.someImage.image = image
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment