Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 阿拉莫菲图像测试_Ios_Swift_Xcode_Alamofireimage - Fatal编程技术网

Ios 阿拉莫菲图像测试

Ios 阿拉莫菲图像测试,ios,swift,xcode,alamofireimage,Ios,Swift,Xcode,Alamofireimage,如何检查AlamofireImage缓存是否正常工作 当我运行应用程序时,我可以看到缓存正在工作-它会重用缓存的图像,而不是在可能的情况下下载它们(缓存可用) 但当我关闭应用程序或重新运行代码时,它不会重用缓存(缓存不存在),因此每次运行时它都会再次下载图像 我如何确保即使在用户关闭并重新打开应用程序后,缓存仍能为其工作 我使用NSLog跳转到系统日志 func loadImage() { if let image = photosManager.cachedImage(for:

如何检查AlamofireImage缓存是否正常工作

当我运行应用程序时,我可以看到缓存正在工作-它会重用缓存的图像,而不是在可能的情况下下载它们(缓存可用)

但当我关闭应用程序或重新运行代码时,它不会重用缓存(缓存不存在),因此每次运行时它都会再次下载图像

我如何确保即使在用户关闭并重新打开应用程序后,缓存仍能为其工作

我使用NSLog跳转到系统日志

func loadImage() {
        if let image = photosManager.cachedImage(for: photo.url) {
            NSLog("Image Cache Found")
            populate(with: image)
            return
        }
        NSLog("Image Cache NOT Found")
        downloadImage()
    }
我从模拟器运行应用程序 我也看到了同样的行为——每次我终止应用程序时,它都会打印“未找到图像缓存”(双击“主页”按钮,然后刷起应用程序)

谢谢