I want to use imageView.af_setImageWithURL(URL)
together with the AutoPurgingImageCache from AlamofireImage.
How can I be informed that af_setImageWithURL
fetched the image, so I can put it into my cache? Because this is done in Background.
I'd prefer something like: imageView.af_imageFromCache(URL)
which sets the image from cache if it is already in there or otherwise downloads async, then sets the image and saves it in the cache.
The shared
ImageDownloader
that theUIImageView
uses already puts the image into theAutoPurgingImageCache
automatically. Every time you use theimageView.af_setImageWithURL(URL)
it will attempt to pull the image out of the image cache if it exists. If the image is not already in the cache, it will start the download on theImageDownloader
instance.SWIFT 4.0
Set 'AutoPurgingImageCache' in Appdelegate so that i can access it in any class
var imageCache:AutoPurgingImageCache?
Then set image in my service class