Wednesday, 15 April 2015

iphone - SDImageCache - imageFromMemoryCache returns nil -



iphone - SDImageCache - imageFromMemoryCache returns nil -

i'm using latest version of sdwebimage (sdimagecache), , saving image code

[[sdimagecache sharedimagecache] storeimage:image forkey:@"1"];

and i'm sure image have been saved successfully, because i've checked app folder, there image existing in it.

and i'm using

uiimage *image = [[sdimagecache sharedimagecache] imagefrommemorycacheforkey:@"1"];

to read image out, image object returns nil. problem be? give thanks you!

when use:

- (void)storeimage:(uiimage *)image forkey:(nsstring *)key

the image saved in disk cache.

the implementation like:

- (void)storeimage:(uiimage *)image forkey:(nsstring *)key { [self storeimage:image imagedata:nil forkey:key todisk:yes]; }

so if need retreive image disk, can utilize next method instead:

- (void)querydiskcacheforkey:(nsstring *)key done:(void (^)(uiimage *image, sdimagecachetype cachetype))doneblock;

the default disk cache type sdimagecachetypenone, if need specify cache type utilize sdimagecachetype enum.

enum sdimagecachetype { /** * image wasn't available sdwebimage caches, downloaded web. */ sdimagecachetypenone = 0, /** * image obtained disk cache. */ sdimagecachetypedisk, /** * image obtained disk cache. */ sdimagecachetypememory };

hope, it'll help you.

iphone ios xcode sdwebimage

No comments:

Post a Comment