gpt4 book ai didi

ios - 清除缓存 AFNetworking 后图像未从磁盘中删除

转载 作者:可可西里 更新时间:2023-11-01 05:43:08 24 4
gpt4 key购买 nike

我尝试清除缓存位后应用程序的大小并没有变得明显变小。

我的应用程序大小约为 30MB,另外还有 45MB 用于缓存图像。

这就是我尝试清除缓存的方式:

 [[NSURLCache sharedURLCache] removeAllCachedResponses];
[[AFImageDownloader defaultURLCache] removeAllCachedResponses];
AFAutoPurgingImageCache *imageCache = [AFImageDownloader defaultInstance].imageCache;
[imageCache removeAllImages];
  • 在我的 iPhone 6 iOS10 上,应用程序的大小没有变小。
  • 在模拟器中的应用程序文件 com.alamofire.imagedownloader/fsCachedData 所有文件仍然存在

这是我使用 AFNetworking (3.1.0) 下载图像的方式:

#import "AFImageDownloader.h"

[photoImageView setImageWithURLRequest:[NSURLRequest requestWithURL:thumb] placeholderImage:myCachedImage success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
[self setPhotoImage:image];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
[self setupPlaceholder];
}];

最佳答案

见下文:

  1. AFAutoPurgingImageCache *imageCache = [AFImageDownloader defaultInstance].imageCache; imageCache是保存在内存中的,做[imageCache removeAllImages];
  2. 您只需执行 [[AFImageDownloader defaultURLCache] removeAllCachedResponses];。它是 Apple 提供的唯一用于清除 URLCache 的 API。
  3. 当您调用 removeAllCachedResponses 时,您发现 fsCachedData 没有被删除。因为苹果有自己的磁盘数据清除机制。可能按照我搜索的那样每隔7天清一次盘数据,但我不能确定。
  4. 我认为看看其他人如何使用 fsCachedData 很有趣。 Should I clear the fsCachedData folder myself?
  5. 希望对你有所帮助。

关于ios - 清除缓存 AFNetworking 后图像未从磁盘中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40513331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com