I use the AlamofireImage library to upload uploaded images.
The code:
import UIKit import AlamofireImage class ViewController: UIViewController { @IBOutlet weak var firstImageView: UIImageView! @IBOutlet weak var secondImageView: UIImageView! let downloader = ImageDownloader() let URLRequest = NSURLRequest(URL: NSURL(string: "https://httpbin.org/image/jpeg")!) override func viewDidLoad() { super.viewDidLoad() requestFirstImage() } func requestFirstImage() { downloader.downloadImage(URLRequest: URLRequest) { response in print(response.request) print(response.response) debugPrint(response.result) if let image = response.result.value { self.firstImageView.image = image self.requestSecondImage() } } } func requestSecondImage() { downloader.downloadImage(URLRequest: URLRequest) { response in print(response.request) print(response.response) debugPrint(response.result) if let image = response.result.value { self.secondImageView.image = image } } } }
Magazine

As shown in the log, the first image is requested, and the second from the cache. No further request is made and the image is displayed instantly.
I expect that when you restart the application, even the first image extracted from the cache, but Log will remain the same. I looked at Library/Caches/.../fsCachedData , and the image is there, ready to receive.
Question: What am I missing here? I need the first image to come from the disk cache on subsequent requests.
ios swift alamofire alamofireimage
Javier cadiz
source share