AlamofireImage
suggest changeAlamofireImage caches images and is built on Alamofire. Install it with CocoaPods:
pod 'AlamofireImage', '~> 3.1'
SetUp:
- Import
AlamofireImageandAlamofire - SetUp the Image cache:
let imageCache = AutoPurgingImageCache( memoryCapacity: 111_111_111, preferredMemoryUsageAfterPurge: 90_000_000) - Making a request and adding the Image to Cache:
Alamofire.request(self.nameUrl[i]).responseImage { response in
if let image = response.result.value {
imageCache.add(image, withIdentifier: self.nameUrl[i])
}
}
- Retrieve Images From Cache:
if let image = imageCache.image(withIdentifier: self.nameUrl[self.a])
{
self.localImageView.image = image
}
For more information, see AlamofireImage.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents