I'm using (trying) AlamofireImage. My saved-to-cache images are not really saved.
my code include:
import Alamofire
import AlamofireImage
let imageCache = AutoPurgingImageCache(
memoryCapacity: 100 * 1024 * 1024,
preferredMemoryUsageAfterPurge: 60 * 1024 * 1024
)
then i am saving an image myself using:
imageCache.add(image, withIdentifier: path)
but in the next run, it always returns nil when i try to fetch this image using the same path:
if let image = imageCache.image(withIdentifier: path){
return image
}
return nil
what am i doing wrong?
- while running\debugging i can see that the imageCache-currentMemoryUsage = 0
Thanks.
This sounds like you're restarting your app. The ImageCache is memory only, and your app's memory is reclaimed when you restart the app.
You don't need to call add() method. I create my custom class which wrap Alamofire Image cache.