ios 清理缓存
- (void)action:(id)sender
{
UIButton * button = sender;
[button setTitle:@"清理完毕" forState:UIControlStateNormal];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *path = [paths lastObject];
NSString *str = [NSString stringWithFormat:@"缓存已清除%.1fM", [self folderSizeAtPath:path]];
NSLog(@"%@",str);
NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:path];
for (NSString *p in files) {
NSError *error;
NSString *Path = [path stringByAppendingPathComponent:p];
if ([[NSFileManager defaultManager] fileExistsAtPath:Path]) {
[[NSFileManager defaultManager] removeItemAtPath:Path error:&error];
}
}