Last active
August 29, 2015 14:26
-
-
Save minikin/eb4457c0aad4c875bcd7 to your computer and use it in GitHub Desktop.
imageFromUrl
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
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