Link to home
Start Free TrialLog in
Avatar of BTMExpert
BTMExpert

asked on

xcode how to save an image

how do you save an image after you take a picture? In my app i'm using an UIImagePickerController that takes the picture but i don't know how to save the image.
ASKER CERTIFIED SOLUTION
Avatar of pgnatyuk
pgnatyuk
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BTMExpert
BTMExpert

ASKER

that helped so much thank you.  One small problem now.  everytime i click the button to save my image, it saves which is great but when i try to do anything else after that, the app crashes.

- (IBAction)saveImage {
      UIImage *image = imageView.image;      

      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image" message:@"Image" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
      [alert show];
      [alert release];
      
      UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}

- (void)image:(UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo {
      NSLog(@"SAVE IMAGE COMPLETE");
      if(error != nil) {
            NSLog(@"ERROR SAVING:%@",[error localizedDescription]);
      }
      [image autorelease];
}
Maybe, because of that line:  [image autorelease];

try to cmment it. If it does not help, comment the alert (all lthree lines about the alert).
 
i took the [image release]; out and it works now. Thanks a lot!!!!!!!