- (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];
}
}
时间: 2024-11-04 15:17:07