Skip to content

Instantly share code, notes, and snippets.

@iksnae
Created July 26, 2016 00:47
Show Gist options
  • Save iksnae/087db8cfcd865243b26e39299384becb to your computer and use it in GitHub Desktop.
Save iksnae/087db8cfcd865243b26e39299384becb to your computer and use it in GitHub Desktop.
extension UIImageView {
public func cachedImage(withURL url_string:String){
if let cached = ImageCache.shared.getImage(key: url_string) {
self.image = cached
}else{
guard let url = NSURL(string: url_string) else { return }
ImageCache.shared.fetchImage(url: url, callback: { (image) in
NSOperationQueue.main().addOperation({
self.image = image
})
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment