Cache online images
AlamofireImage
Section titled “AlamofireImage”Caching Online Images Using AlamofireImage. It works on top of Alamofire in Swift.
Install AlamofireImage using cocoapods
pod 'AlamofireImage', '~> 3.1'SetUp:
- Import
AlamofireImageandAlamofire
Alamofire.request(self.nameUrl[i]).responseImage { response in if response.result.value != nil { let image = UIImage(data: response.data!, scale: 1.0)! 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 Info follow this link