in iphone i have requirement of store image in cache .
but how i can store this in cache.
I know the folder path of cache. is this only way i have to WRITE
You can store data on local disk using NSArchiver
and NSUnarchiver
in this way:
// set your image in cache
NSData *imgData = [NSKeyedArchiver archivedDataWithRootObject:myImage];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:imgData forKey:@"img_01"];
[defaults synchronize];
//get your image from cache
NSData *imgData = [[NSUserDefaults standardUserDefaults] objectForKey:@"img_01"];
myImage = [NSKeyedUnarchiver unarchiveObjectWithData:imgData];
Reference apple here: http://goo.gl/XH2o2
hope this helps.
use this link..
http://www.makebetterthings.com/iphone/image-caching-in-iphone-sdk/
edited:
get file path using this code and fatch the particular file :
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [paths objectAtIndex:0];