为了账号安全,请及时绑定邮箱和手机立即绑定

iOS开发,清除缓存功能在iOS8上有效,在iOS9和10上无效

iOS开发,清除缓存功能在iOS8上有效,在iOS9和10上无效

iOS
繁星点点滴滴 2018-07-26 21:14:14
清除缓存的代码如下:// 清理缓存    NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];    NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachePath];    NSLog(@"文件数 :%ld",[files count]);    for (NSString *p in files)    {        NSError *error;        NSString *path = [cachePath stringByAppendingString:[NSString stringWithFormat:@"/%@",p]];        if([[NSFileManager defaultManager] fileExistsAtPath:path])        {            [[NSFileManager defaultManager] removeItemAtPath:path error:&error];        }    }在iOS8上可以清理缓存,在iOS9 和 iOS10上无效。
查看完整描述

2 回答

?
长风秋雁

TA贡献1757条经验 获得超7个赞

项目中用了一个图片库:EGOImageView 清理缓存要用这个库自己的清理方法

查看完整回答
反对 回复 2018-07-31
  • 2 回答
  • 0 关注
  • 695 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信