Xcode: SDWebImage clear cache for single image

余生颓废 提交于 2019-12-05 11:45:02

问题


I'm using SDWebImage to asynchronous image downloader with cache support.

It's working perfectly except that sometimes the image got updated on the server with same name, thus I need to clear it from client device cache but no success!

I found here that I have to use "removeImageForKey" but it's not recognized by Xcode!

I'm using the following code to set the image:

[imgPic setImageWithURL:[NSURL URLWithString:@"http://domain.com/image.jpg"] placeholderImage:[UIImage imageNamed:@"tmpPic.png"]];

What's the correct way to call removeImageForKey? What do I have to import rather than UIImageView+WebCache.h?


回答1:


- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk;

API is right. It work for me. Do you know the api is in class SDImageCache which is a singleton class.
You could use it like this:

[[SDImageCache sharedImageCache] removeImageForKey:image_url fromDisk:YES];



回答2:


#import "SDImageCache.h"

....

[[SDImageCache sharedImageCache] removeImageForKey:@"http://domain.com/image.jpg" fromDisk:YES];


来源:https://stackoverflow.com/questions/11888578/xcode-sdwebimage-clear-cache-for-single-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!