Hey, I'm new to iPhone, and recently I tried to make an app. Basically, I want the user to be able to capture any image from the camera, and then save it to the device gallery. I know how to save a photo in the gallery, it works for me, but I had problems saving all captured images to a specific folder (for example, a new album) in the device gallery. I want the user to be able to take several pictures and then copy the images from this particular folder to the gallery.
here is my code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
UIImage *photoTaken = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
self.imageView.image = photoTaken;
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(photoTaken, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
}
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
UIAlertView *alert;
if (error) {
alert = [[UIAlertView alloc] initWithTitle:@"Error!"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
I tried to do this below the code, but I donβt know where it saves the images to the application resource on my iPhone device:
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"EMS_FOLDER"];
NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"Files"];
Any source or link for reference is welcome. Thanks for the help!