您的位置:首页 > 其它

SDWebImage手动清除缓存的方法

2015-08-21 21:15 387 查看
1.找到SDImageCache类

2.计算缓存大小的方法:

[objc] view
plaincopy





- (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];

}

});

return size;

}

3.

[objc] view
plaincopy





// 清除缓存

[[SDImageCache sharedImageCache] clearDisk];


原文地址:原文地址
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: