iOS 清除缓存(笔记)

2015-12-31  本文已影响389人  赵永洪

float tmpSize = [[SDImageCache sharedImageCache] getSize];

NSString *clearMessage = tmpSize >= 1024 * 1024 ? [NSString stringWithFormat:@"清理缓存(%.2fM)" , tmpSize / 1024 / 1024] : [NSString stringWithFormat:@"清理缓存(%.2fK)", tmpSize / 1024];


UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:clearMessage preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

}];


UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

[[SDImageCache sharedImageCache]clearDisk];

//清除内存缓存

[[[SDWebImageManager sharedManager] imageCache] clearMemory];

//清除系统缓存

[[NSURLCache sharedURLCache] removeAllCachedResponses];

}];


[alert addAction:action2];

[alert addAction:action1];

[self presentViewController:alert animated:YES completion:nil];

上一篇下一篇

猜你喜欢

热点阅读