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
}
)
From the
SDWebImageManager
class thedownloadImageWithURL:
methodSo if the image is present in cache you are already retrieving it with your code, instead of downloading from the web.
As far as I know (I just looked up the author's Git page) there is the following method to directly access an image which is stored inside the cache-
You can use the SDImageCache to store an image explicitly to the cache with the following code:
Where myImage is the image you want to store and myCacheKey is a unique identifier for the image.
After you stored an image to the cache and want to use that image, just do the following:
This code is Objective-C code, you have to "convert" it to swift yourself.
I hope I could help you!
Thanks for answer @beeef but SDWebImage has been updated some part of code: Save image:
Get image from disk cache: