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_Alamofire_Alamofireimage - Fatal编程技术网

Ios 阿拉莫菲图像缓存?

Ios 阿拉莫菲图像缓存?,ios,swift,alamofire,alamofireimage,Ios,Swift,Alamofire,Alamofireimage,我将AlamofireImage与PromiseKit和Alamofire结合使用。我使用承诺来链接x数量的图片下载,因为我想同步完成这项工作。我似乎无法理解是ImageDownloader()自动缓存,还是必须将图像显式添加到缓存中?到目前为止,我看到的唯一例子是没有使用ImageDownloader,因此我很难找到答案 如果没有-如何将其添加到缓存中?我试过使用: self.imageDownloader.imageCache?.addImage(image, withIdentifier:

我将
AlamofireImage
PromiseKit
Alamofire
结合使用。我使用承诺来链接x数量的图片下载,因为我想同步完成这项工作。我似乎无法理解是
ImageDownloader()
自动缓存,还是必须将图像显式添加到缓存中?到目前为止,我看到的唯一例子是没有使用
ImageDownloader
,因此我很难找到答案

如果没有-如何将其添加到缓存中?我试过使用:

self.imageDownloader.imageCache?.addImage(image, withIdentifier: imageUrl)

但它所能做的就是永远提高我的内存使用率(即反复向缓存中添加相同的图像)

我认为定义AutoPurgingImageCache()并在缓存过程中使用它需要解决内存使用问题

let photoCache = AutoPurgingImageCache(
    memoryCapacity: 100 * 1024 * 1024,
    preferredMemoryUsageAfterPurge: 60 * 1024 * 1024
)
您可以更改内存容量首选内存在清除后表示MB。要在缓存中添加任何图像,可以使用以下命令:

photoCache.addImage(scaledImage, withIdentifier: urlString)

您还可以查看更多详细信息和页面。

我认为定义AutoPurgingImageCache()并在缓存过程中使用它需要解决内存使用问题

let photoCache = AutoPurgingImageCache(
    memoryCapacity: 100 * 1024 * 1024,
    preferredMemoryUsageAfterPurge: 60 * 1024 * 1024
)
您可以更改内存容量首选内存在清除后表示MB。要在缓存中添加任何图像,可以使用以下命令:

photoCache.addImage(scaledImage, withIdentifier: urlString)

您还可以查看更多详细信息和页面。

我也使用了与您在这里相同的方法。但根据API参考,图像应自动添加到缓存:

每个下载的图像都缓存在底层NSURLCache以及支持图像过滤器的内存中图像缓存中。


我也使用了与您在这里相同的方法。但根据API参考,图像应自动添加到缓存:

每个下载的图像都缓存在底层NSURLCache以及支持图像过滤器的内存中图像缓存中。


这里有一个小的语法错误。要将图像添加到缓存中,您可以调用
.add
而不是
。addImage
有一个小的语法错误。要将图像添加到缓存中,您可以调用
.add
,而不是
.addImage