【iOS知识学习】_iPhone清理缓存

来源:互联网 发布:js websocket链接不了 编辑:程序博客网 时间:2024/05/27 06:16

//清理缓存

-(void)cleanCache{

   dispatch_async(

                  dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)

                   , ^{

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

                       

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

                      NSLog(@"files :%d",[filescount]);

                      for (NSString *pin files) {

                          NSError *error;

                          NSString *path = [cachPath stringByAppendingPathComponent:p];

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

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

                           }

                       }

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

}


-(void)Success

{

    [SVProgressHUDshowSuccessWithStatus:@"清理成功"];

}

0 0