Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: SDWebImage clear cache for single image

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?

like image 235
DeZigny Avatar asked Aug 09 '12 17:08

DeZigny


2 Answers

- (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];
like image 89
jtianling Avatar answered Oct 17 '22 11:10

jtianling


#import "SDImageCache.h"

....

[[SDImageCache sharedImageCache] removeImageForKey:@"http://domain.com/image.jpg" fromDisk:YES];
like image 23
SEG Avatar answered Oct 17 '22 11:10

SEG