一段异步操作的代码(清理缓存)
2013-12-05 11:16
302 查看
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(clearCacheSuccess) withObject:nil waitUntilDone:YES];}); -(void)clearCacheSuccess { NSLog(@"清理成功"); }
相关文章推荐
- 一段异步操作的代码(清理缓存)
- 【代码笔记】iOS-实现网络图片的异步加载和缓存
- C#控制IE进程关闭和缓存清理的实现代码
- NSOperation之为UItabView制作图片缓存——在didReceiveMemoryWarning方法中做图片缓存的清理操作
- Redis-RedisTemplate 缓存操作具体实现代码
- 如何在VB中操作EXCEL(一段代码,两个可以使用的过程)
- 一段python 代码(涉及编解码,整数的除法运算,文件操作)
- 如何清理asp站点缓存的代码
- 如何清理asp站点缓存的代码?
- ASIO官方例子学习1.为服务器异步操作定制内存分配模型代码分析(allocation/server.cpp)
- java中对Redis的缓存进行操作的示例代码
- C#中清理缓存代码
- c#异步执行一段代码
- 自己觉得比较有用的WindowsPhone7 Http异步请求的一段简单代码
- ajax同步与异步加载和缓存清理设置
- Linux串口操作的一段代码
- [C++基础]036_一段关于指针的误操作代码
- 原子操作的一段代码学到的知识
- SDWebImage异步加载图片及缓存的管理与清理
- 一段可以清理NSArray中的空对象的代码(递归)