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

     

    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(@"清理成功");

    }

  • 相关阅读:
    UVALive 7276 Wooden Signs
    hdu4291 A Short problem
    A
    hdu4686 Arc of Dream
    thinkphp5 模型的 更新操作
    thinkphp5 模型的 新增操作
    thinkphp 模型的创建
    thinkphp5 增删改查操作
    tp5 的查询构造器
    thinkphp5 数据库的原生查询
  • 原文地址:https://www.cnblogs.com/iOS-mt/p/4744432.html
Copyright © 2011-2022 走看看