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];
       });
    }
  • 相关阅读:
    记一次渗透测试(5)
    记一次渗透实战(一)
    Spring IOC/DI
    Mysql 索引
    Mysql 存储过程
    Mysql 视图
    Mysql 用户和权限
    Mysql 事务
    Mysql 常用函数
    Mysql 子查询
  • 原文地址:https://www.cnblogs.com/cchHers/p/8711943.html
Copyright © 2011-2022 走看看