1.找到SDImageCache类
2.计算缓存大小的方法:
- (NSUInteger)getSize {
__block NSUInteger size =0;
dispatch_sync(self.ioQueue, ^{
NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath];
for (NSString *fileName in fileEnumerator) {
NSString *filePath = [self.diskCachePath stringByAppendingPathComponent:fileName];
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
size += [attrs fileSize];
}
});
returnsize;
}
3.
// 清除缓存
[[SDImageCaches haredImageCache] clearDisk];