获取SDWebImage的缓存大小并清除
// 获取SDWebImage的缓存大小
- (NSString *)cacheSizeFormat { NSString *sizeUnitString; float size = [SDWebImageManager.sharedManager.imageCache getSize]; if(size < 1024){ sizeUnitString = [NSString stringWithFormat:@"%.1fb",size]; }else if (size > 1024 && size < 1024 * 1024) { size /= 1024.0; sizeUnitString = [NSString stringWithFormat:@"%.1fkb",size]; } else{ size /= (1024.0 * 1024); sizeUnitString = [NSString stringWithFormat:@"%.1fM",size]; } return sizeUnitString; }
//清除SDWebImage的缓存
else if ([selectText isEqualToString:@"清除缓存"]) { [[[SDWebImageManager sharedManager] imageCache] clearDisk]; [[[SDWebImageManager sharedManager] imageCache] clearMemory]; __weak typeof(self) weakSelf = self; dispatch_queue_t queue = dispatch_get_main_queue(); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), queue, ^{ [MBProgressHUD showMessage:@"缓存清除成功"]; [weakSelf reloadData]; }); }