`
seemefly163_0
  • 浏览: 19729 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
最近访客 更多访客>>
社区版块
存档分类
最新评论

清除SDImageCache的缓存

阅读更多

- (void)showInfo
{
    NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:diskCachePath];
    int i = 0;
    float total = 0.0f;
    NSNumberFormatter *numberFormatter =[[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat: @"#,##0.## bytes"];
    for (NSString *fileName in fileEnumerator){
        NSLog(@"filename %d  :  %@", i, fileName);
        NSString *filePath = [diskCachePath stringByAppendingPathComponent:fileName];
        NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
        if (attrs) {
            //获取文件的字节大小
            NSNumber *fileSize = (NSNumber*)[attrs objectForKey: NSFileSize];
            total = [fileSize floatValue] + total;
            //格式化文件大小
            NSString *A = [numberFormatter stringFromNumber: fileSize];
            NSLog(@"filesize %d  :  %@", i, A);
        }
        ++i;
    }
    NSLog(@"%f bytes (%f M) in cache", total, total / 1024.0 / 1024.0);
    [numberFormatter release];
}


SDImageCache *cache = [SDImageCachesharedImageCache];

            NSLog(@"cache 位置: %@", [cache getDiskCachePath]);

            [cache clearDisk];

            [cache clearMemory];

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics