iOS清除缓存
来源:互联网 发布:淘宝v达人 编辑:程序博客网 时间:2024/05/19 23:05
参考:http://www.open-open.com/lib/view/open1425625126743.html
-(float)fileSizeAtPath:(NSString *)path{
NSFileManager *fileManager=[NSFileManagerdefaultManager];
if([fileManager fileExistsAtPath:path]){
long long size=[fileManagerattributesOfItemAtPath:path error:nil].fileSize;
return size/1024.0/1024.0;
}
return 0;
}
-(float)folderSizeAtPath:(NSString *)path{
NSFileManager *fileManager=[NSFileManagerdefaultManager];
float folderSize;
if ([fileManager fileExistsAtPath:path]) {
NSArray *childerFiles=[fileManager subpathsAtPath:path];
for (NSString *fileNamein childerFiles) {
NSString *absolutePath=[path stringByAppendingPathComponent:fileName];
folderSize +=[self fileSizeAtPath:absolutePath];
}
//SDWebImage框架自身计算缓存的实现
folderSize+=[[SDImageCache sharedImageCache] getSize]/1024.0/1024.0;
return folderSize;
}
return 0;
}
-(void)clearCache:(NSString *)path{
NSFileManager *fileManager=[NSFileManagerdefaultManager];
if ([fileManager fileExistsAtPath:path]) {
NSArray *childerFiles=[fileManager subpathsAtPath:path];
for (NSString *fileNamein childerFiles) {
//如有需要,加入条件,过滤掉不想删除的文件
NSString *absolutePath=[path stringByAppendingPathComponent:fileName];
[fileManager removeItemAtPath:absolutePatherror:nil];
}
}
[[SDImageCachesharedImageCache] cleanDisk];
}
NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) objectAtIndex:0]; //获取的缓存文件夹路径
- ios webview清除缓存。
- ios webview清除缓存
- iOS开发清除缓存
- ios webview清除缓存
- ios webview清除缓存
- ios webview清除缓存
- IOS清除缓存
- iOS清除缓存
- 清除ios的缓存
- iOS 清除缓存
- iOS 清除缓存
- iOS 清除缓存
- iOS清除缓存
- iOS清除缓存
- iOS 清除缓存
- iOS 清除缓存
- iOS ---清除缓存
- ios清除缓存2
- libsqlite3.dylib找不到
- redis内部数据结构--简单动态字符串sds
- RxJava 转换操作符groupBy
- 推荐提升 Android 性能的建议
- IOS学习 NSNavigationController 多个子页面间相互跳转
- iOS清除缓存
- oracle 跟踪事件 set event
- GridView使用的技巧
- lua获取当时时间
- VS2010下设置GDI+
- 64位CentOs6.5系统阿里云服务器源码安装MySql5
- Android进阶——安卓调用ESC/POS打印机打印
- js两种拼接字符串方法
- Linux 4.3.3编译