zoukankan      html  css  js  c++  java
  • 获取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];
       });
    }
  • 相关阅读:
    Excel表格函数逻辑排错
    MobaXterm体验最好的SSH客户端
    Excel中的常用函数
    Shell 知识点2020
    Linux 知识点2020
    Python知识点2020
    es6 模版字符串
    es6对象定义简写
    es6解构赋值
    ES6 let const关键字
  • 原文地址:https://www.cnblogs.com/cchHers/p/8711943.html
Copyright © 2011-2022 走看看