删除图像缓存
问题描述:
我正在使用AfNetworking版本〜> 1.3.4,它是由cocoaPods添加的。我无法升级到2.0,因为我的应用程序中使用了大多数方法。删除图像缓存
AFImageCache(在的UIImageView + AFNetworking)时具有相同URL的新图像被用于
不能被清除我应该添加以下方法中的“的UIImageView + AFNetworking”类此。
+ (void)clearCachedImages {
[[[self class] af_sharedImageCache] removeAllObjects];
}
由于AFNetworking是在我的cocoaPods。我无法添加。 请帮我如何通过类别/子类添加此方法?
编辑:
我曾尝试以下
@class AFImageCache;
@interface SPUtility : NSObject
{
}
@end
@implementation SPUtility
+ (void)clearCachedImages {
[[AFImageCache af_sharedImageCache] removeAllObjects]; //shows following error
}
@end
错误:没有已知的类方法用于选择 'af_sharedImageCache' 2.接收 'AFImageCache' 的类消息为转发宣言
答
作为UIImageView
的一个类别,因为您的af_sharedImageCache
在
SPUtility.m
@interface UIImageView (MyMethods)
+ (NSCache *)af_sharedImageCache;
@end
//you don't have to implement method since it's already defined in UIImageView (AFNetworking)
//It's just for the happiness of the compiler
@implementation SPUtility
+ (void)clearCachedImages {
[[UIImageView af_sharedImageCache] removeAllObjects];
}
@end
你为什么无法添加。转到pod项目并打开该文件并添加此方法。如果我更新吊舱,我的方法将会丢弃,您将面临哪些困难 – 2014-08-27 10:36:29
becoz。它会回到原来的。 – Myaaoonn 2014-08-27 10:57:24