finding photo library image path

Discussion in 'iOS Programming' started by XcodeNewb, Jun 3, 2009.

  1. XcodeNewb macrumors member

    Feb 6, 2009
    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?

  2. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    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.

Share This Page