Created
October 19, 2014 19:11
-
-
Save toast38coza/f3f2409ec86516e6c985 to your computer and use it in GitHub Desktop.
Fetch an image from the web
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
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