PDA

View Full Version : finding photo library image path




XcodeNewb
Jun 3, 2009, 08:49 PM
I have searched everywhere and cannot find a definite answer about this.

When I pick an image form the photo library I would like to save it to a file and reload it the next time the user runs the app.

How exactly can I get the image the user picked and save it somewhere to access later.

I tried this but it dies not seem to save the image:


NSString *newFilePath = [NSHomeDirectory() stringByAppendingPathComponent: @"ChosenPic.jpg"];

NSData * imageData = UIImageJPEGRepresentation(image, 1.0);
//data = imageData;
if (imageData != nil) {
NSLog(@"HERE [%@]", newFilePath);
[imageData writeToFile:newFilePath atomically:YES];
}

imageView.image =[UIImage imageNamed:newFilePath];


Any ideas?

Thanks



Darkroom
Jun 3, 2009, 09:18 PM
i'm pretty sure you can select and image from the camera roll and just save it's path to your app's user defaults.

[EDIT] also, i don't think you can use NSHomeDirectory() with cocoa touch. apps are sandboxed with documents, library and tmp folders.