SDWebImage清理图片缓存方法
//获取当前缓存大小 @property (nonatomic, assign) NSUInteger tmpSize; //获取缓存大小并储存 _tmpSize=[[SDImageCache sharedImageCache]getSize]; NSString* tempSize=[NSString stringWithFormat:@"%.2fM", self.tmpSize /1024.f /1024.f]; [[NSUserDefaults standardUserDefaults]setObject:tempSize forKey:@"tempSize”]; [[SDImageCache sharedImageCache]clearDisk]; [[SDImageCache sharedImageCache]clearMemory]; __weak typeof(self) myself = self; [[SDImageCache sharedImageCache]calculateSizeWithCompletionBlock:^(NSUInteger fileCount, NSUInteger totalSize) { NSLog(@"%lu", (unsigned long)totalSize); [myself refreshCache]; }]; /** * 缓存清理完毕后刷新数据 */ -(void)refreshCache { NSString* tempSize=[[NSUserDefaults standardUserDefaults]objectForKey:@"tempSize"]; NSString *str = [NSString stringWithFormat:@"缓存清理成功,共清理了%@缓存",tempSize]; ALERT_HOME(@"清理成功", str); [_shezhiTableView reloadData]; }
“人生苦短,不要把时间浪费在犹豫不决上,喜欢的东西就去买,喜欢的人就去追。”