ios 清理缓存
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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];
}
}
以上是关于ios 清理缓存的主要内容,如果未能解决你的问题,请参考以下文章