Skip to content

Instantly share code, notes, and snippets.

@minikin
Last active August 29, 2015 14:26
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 minikin/eb4457c0aad4c875bcd7 to your computer and use it in GitHub Desktop.
Save minikin/eb4457c0aad4c875bcd7 to your computer and use it in GitHub Desktop.
imageFromUrl
import UIKit
extension UIImageView {
public func imageFromUrl(urlString: String) {
if let url = NSURL(string: urlString) {
let request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {
(response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
self.image = UIImage(data: data)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment