草庐IT

AutoPurgingImageCache

全部标签

ios - Alamofire:af_setImageWithURL 和 ImageDownloader 是否共享同一个 AutoPurgingImageCache?

我在我的项目中经常使用AlamofireImage将图像设置为UIImageView:letimageView=UIImageView(frame:frame)letURL=NSURL(string:"https://httpbin.org/image/png")!imageView.af_setImageWithURL(URL)在我的应用程序中的某个时刻,我需要直接获取图像,因为除了将它设置为UIImageView之外,我还想做其他事情。AlamofireImage为这个用例提供了ImageDownloader:letdownloader=ImageDownloader()letUR

ios - Alamofire 图片 : Fetch Image from AutoPurgingImageCache after af_setImageWithURL()

我在我的项目中使用AlamofireImage。我经常使用someImageView.af_setImageWithURL(url)。但是在某些时候我需要从imageCache中手动获取图像,因为我不想将它应用到UIImageView。这带来了两个问题:我可以通过使用letimageCache=AutoPurgingImageCache()创建图像缓存来直接访问图像缓存。这是否与.af_setImageWithURL()使用的相同的缓存(单例)?或者这是一个新的?这对我来说毫无值(value),因为我无法从预填充缓存中获利。鉴于这是相同的缓存:我怎样才能获取正确的图像?我想到了imag