用以下代码遍历清除缓存:
NSString *cachesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
NSFileManager *fileManager = [NSFileManager defaultManager];
//获取当前路径下所有文件的子路径数组
NSArray *subFilePaths = [fileManager subpathsAtPath:cachesPath];
//遍历数组
for (NSString *subFilePath in subFilePaths) {
//拼接完整路径
NSString *path = [cachesPath stringByAppendingPathComponent:subFilePath];
[fileManager removeItemAtPath:path error:nil];
}
但是在真机上会有102b的剩余,在模拟器上没有是为什么呢?
模拟器是仿造对我目录 对于缓存这些可能没有
真机和模拟器是有区别的.