zoukankan      html  css  js  c++  java
  • ios 清理缓存

    一段清理缓存的代码如下:

    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:nilwaitUntilDone:YES];});


    -(void)clearCacheSuccess

    {

        NSLog(@"清理成功");

    }

     
     
     
  • 相关阅读:
    Best Time to Buy and Sell Stock(动态规划)
    word break
    Container With Most Water
    Partition List(链表的插入和删除操作,找前驱节点)
    取样问题(编程珠玑)
    统计指标
    脚本化加载文件与转储
    azkaban调度
    hive自定义UDTF函数叉分函数
    hive数据仓库建设
  • 原文地址:https://www.cnblogs.com/yhj1787354782/p/5115732.html
Copyright © 2011-2022 走看看