29,031
社区成员
发帖
与我相关
我的任务
分享
-(void)removeCache
{
//===============清除缓存==============
NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachePath];
// NSLog(@"文件数 :%lu",(unsigned long)[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];
}
}
}