SDWebImage 获取缓存大小

//获取缓存的大小  

//在获取缓存的方法写上这两句代码

NSUInteger intg = [[SDImageCache sharedImageCache] getSize];
//
NSString * currentVolum = [NSString stringWithFormat:@"%@",[self fileSizeWithInterge:intg]];

//计算出大小
- (NSString *)fileSizeWithInterge:(NSInteger)size{
    // 1k = 1024, 1m = 1024k
    if (size < 1024) {// 小于1k
        return [NSString stringWithFormat:@"%ldB",(long)size];
    }else if (size < 1024 * 1024){// 小于1m
        CGFloat aFloat = size/1024;
        return [NSString stringWithFormat:@"%.0fK",aFloat];
    }else if (size < 1024 * 1024 * 1024){// 小于1G
        CGFloat aFloat = size/(1024 * 1024);
        return [NSString stringWithFormat:@"%.1fM",aFloat];
    }else{
        CGFloat aFloat = size/(1024*1024*1024);
        return [NSString stringWithFormat:@"%.1fG",aFloat];
    }
}

你可能感兴趣的:(objective-c,SDWebImage,获取缓存大小,SDWebImage,获取缓存大小,SDW,缓存)