iOS calculates SDWebImage local cached image size + cleans up locally cached images

#import "SDImageCache.h"

// Calculate the size of SDWebImage's local cache image

+ (NSString *)getCacheSize {

    float tmpSize = [[SDImageCache sharedImageCache] getSize];

    NSLog(@"%f",tmpSize);

    NSString *size =

    tmpSize/1024 <= 1024 ?

    [NSString stringWithFormat:@"%.1fK",tmpSize/1024] :

    [NSString stringWithFormat:@"%.1fM",tmpSize/1024/1024];

    return size;

    

}

// clear image cache

+(void)clearDisk{

    [[ SDImageCache sharedImageCache ] clearDisk ]; // Clear locally cached images

    

    [[ SDImageCache sharedImageCache ] clearMemory ]; // clear the memory image

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325567858&siteId=291194637