//清除缓存
- (float)checkTmpSize;
- (float)checkTmpSize {
float totalSize = 0;
NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:_diskCachePath];
for (NSString *fileName in fileEnumerator) {
NSString *filePath = [_diskCachePath stringByAppendingPathComponent:fileName];
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
unsigned long long length = [attrs fileSize];
totalSize += length / 1024.0 / 1024.0;
}
NSLog(@"tmp size is %.2fM",totalSize);
return totalSize;
}
#import "SDImageCache.h"
CGFloat s = [[SDImageCache sharedImageCache] checkTmpSize];
cell.lLabel.text = [NSString stringWithFormat:@"%.2fMB",s];
```
```
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 && indexPath.row == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"确定要清除缓存么" delegate:self cancelButtonTitle:@"取消"otherButtonTitles:@"清除", nil];
alert.tag = 100;
[alert show];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
break;
case 1:
[[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
// [CHNotices noticesWithTitle:@"删除成功" Time:1 View:self.view Style:CHNoticesStyleSuccess];
NSLog(@"123121234412412412");
[self.tableView reloadData];
}];
break;
}
}
```