user564968
user564968

Reputation:

how to store image in local iphone bundel

i have one application in that i download all data in local .

in this data also image coming i want to store this image in local .

can i store this image in local? if yes ! how ?

from online image path (url) coming.

Upvotes: 0

Views: 800

Answers (1)

Save the image in UIImage and then save it to local like this;

NSData *imageData = UIImagePNGRepresentation(image);
        NSString *imageName = [NSString stringWithFormat:@"image.png"];

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
        [imageData writeToFile:fullPathToFile atomically:YES];

Upvotes: 1

Related Questions