清除緩存的代碼如下:// 清理緩存 NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachePath]; NSLog(@"文件數(shù) :%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上無效。
iOS開發(fā),清除緩存功能在iOS8上有效,在iOS9和10上無效
繁星點(diǎn)點(diǎn)滴滴
2018-07-26 21:14:14