New to AFImage. I'm not sure if this is the correct way to grab an image and have it cached. Seems like it is not hitting the server everytime this is running but I'm not sure if it is being cached? I'm getting lucky? It also appears the the syntax I'm using below is dated...
Any comment appreciated.
Alamofire.request("https://www.website.com/advertising/images/"+whichad!)
.responseImage { response in
if let image = response.result.value {
//print("image downloaded: \(image)")
self.ad1image.image = image
}
else{
self.ad1image.image = UIImage(named: "TWITlogoSQ")
}
}`
When you load images with
Alamofire.request("url").responseImage
, downloaded images will be cached only with URLCache, which behaviour depends of Cache-Control headers and URLCache has some limitationsIts better to use
af_setImage()
. This method uses a combination of anURLCache
andAutoPurgingImageCache
to create a very robust, high performance image caching system.for example