0

I am making an iphone application in which

1) i want to take the picture in an application that i know how to do 2) now i want to save that picture in specified folder of an application only. Is it possible to do so. Any help will be really appreciated.

Thank you

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Did You gone through it - http://stackoverflow.com/questions/6821517/save-an-image-to-application-documents-folder-from-uiview-on-ios – Kumar KL Jun 22 '13 at 04:33

1 Answers1

3

Try this

You can use the following code in UIImagePickerControllerDelegate delegate implementation

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

//obtaining saving path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"latest_photo.png"];

//extracting image from the picker and saving it
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];   
if ([mediaType isEqualToString:@"public.image"]){
    UIImage *editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
    NSData *webData = UIImagePNGRepresentation(editedImage);
    [webData writeToFile:imagePath atomically:YES];
}
}
Ravindhiran
  • 5,304
  • 9
  • 50
  • 82