【iOS知识学习】_iPhone清理缓存
2015-05-11 18:50
288 查看
//清理缓存
-(void)cleanCache{
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0)
, ^{
NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,
YES) objectAtIndex:0];
NSArray *files = [[NSFileManager
defaultManager] subpathsAtPath:cachPath];
NSLog(@"files :%d",[files
count]);
for (NSString *p
in files) {
NSError *error;
NSString *path = [cachPath
stringByAppendingPathComponent:p];
if ([[NSFileManager
defaultManager] fileExistsAtPath:path]) {
[[NSFileManager
defaultManager] removeItemAtPath:path
error:&error];
}
}
[self
performSelectorOnMainThread:@selector(Success)
withObject:nil
waitUntilDone:YES];});
}
-(void)Success
{
[SVProgressHUD
showSuccessWithStatus:@"清理成功"];
}
-(void)cleanCache{
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0)
, ^{
NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,
YES) objectAtIndex:0];
NSArray *files = [[NSFileManager
defaultManager] subpathsAtPath:cachPath];
NSLog(@"files :%d",[files
count]);
for (NSString *p
in files) {
NSError *error;
NSString *path = [cachPath
stringByAppendingPathComponent:p];
if ([[NSFileManager
defaultManager] fileExistsAtPath:path]) {
[[NSFileManager
defaultManager] removeItemAtPath:path
error:&error];
}
}
[self
performSelectorOnMainThread:@selector(Success)
withObject:nil
waitUntilDone:YES];});
}
-(void)Success
{
[SVProgressHUD
showSuccessWithStatus:@"清理成功"];
}
相关文章推荐
- 【iOS知识学习】_iPhone学习基于UIKeyboardTypeDecimalPad(数字键盘+小数点)
- 【iOS知识学习】_iPhone学习提交git@OSC
- 【iOS知识学习】_iPhone学习访问联系人
- 【iOS知识学习】_iPhone邮箱身份证电话号码验证
- 【iOS知识学习】_iPhone开发必经
- 【iOS知识学习】_iPhone学习四舍五入函数
- 【iOS知识学习】_iPhone学习多个UITextField 键盘弹起
- 【iOS知识学习】_iPhone 之 Cer P12 Mobileprovition 文件
- 【iOS知识学习】_iPhone判定金额小数点相关代码
- 【iOS知识学习】_iPhone学习微信分享到好友/短信
- iOS学习总结之清理缓存
- ios学习--iphone 防止键盘挡住UITextField解决方案
- 2011斯坦福大学iOS应用开发教程学习笔记(第七课)Pad和iPhone的通用程序
- IOS 开发学习二 C语言知识 字符串处理
- iOS 清理应用缓存
- iOS - 清理缓存
- IOS 多线程知识学习
- 【原】iOS学习之PINCache第三方缓存框架
- iOS 开发过程中----清理缓存的实现
- IOS 核心开发课程---学习步骤---应该掌握的知识