Sydney Loteria Sydney Loteria - 7 months ago 178
Swift Question

Get SDWebImage Cache Image

I would like to ask on how to get the downloaded image after the SDWebImageManager downloaded it. I have only the code to download it via URL, here's what I got:

let manager: SDWebImageManager = SDWebImageManager.sharedManager()
manager.downloadImageWithURL(NSURL(string: feedDetails.thumbnail), options: [],
progress: {(receivedSize: Int, expectedSize: Int) -> Void in
print(receivedSize)
},
completed: {(image, error, cached, finished, url) -> Void in

self.feedImage.image = image
}
)

Answer

From the SDWebImageManager class the downloadImageWithURL: method

Downloads the image at the given URL if not present in cache or return the cached version otherwise.

So if the image is present in cache you are already retrieving it with your code, instead of downloading from the web.