ios简单的清除缓存代码

清除缓存 下面是清除图片缓存SDImageCachewebview也有自己的清除缓存的方法
1.清除缓存 把缓存存在默认cache中
把缓存量显示出来
self.Clear.text = [NSStringstringWithFormat:@"%.2fM", [selfgetCacheSize]];
清除缓存
[[SDImageCachesharedImageCache]clearDisk];
[[NSFileManagerdefaultManager] removeItemAtPath:[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES)lastObject]error:nil];
计算缓存量
- (double)getCacheSize {
SDImageCache *imageCache = [SDImageCachesharedImageCache];
NSUInteger fileSize = [imageCache getSize]; //以字节为单位
NSString *myCachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES)lastObject];
NSFileManager *fm = [NSFileManagerdefaultManager];
NSDictionary *fileInfo = [fm attributesOfItemAtPath:myCachePatherror:nil];
fileSize += fileInfo.fileSize;
return fileSize/1024.0/1024.0;
【ios简单的清除缓存代码】}

    推荐阅读