清理缓存

来源:互联网 发布:rar解压软件下载 免费 编辑:程序博客网 时间:2024/04/29 23:23

-(void)myClearCacheAction{

    dispatch_async(

                   dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)

                   , ^{

                       NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask, YES)objectAtIndex:0];

                       

                      NSArray *files = [[NSFileManagerdefaultManager] subpathsAtPath:cachPath];

                      DebugLog(@"files :%lu",(unsignedlong)[files count]);

                      for (NSString *pin files) {

                          NSError *error;

                          NSString *path = [cachPath stringByAppendingPathComponent:p];

                          if ([[NSFileManagerdefaultManager] fileExistsAtPath:path]) {

                               [[NSFileManagerdefaultManager] removeItemAtPath:patherror:&error];

                           }

                       }

                       [selfperformSelectorOnMainThread:@selector(clearCacheSuccess)withObject:nilwaitUntilDone:YES];});

}

0 0