Hey I'm new to iPhone and I have been trying to make an app recently. Basically, what I want to do is if user will capture any image from camera, then it should save in the device gallery. I know how to save the photo in gallery, it's working for me, but I am having trouble with to save all the captured images into a specific folder (like a new album) in device gallery. I want the user to be able to take several pictures and then copy pictures from that specific 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;
//Save Photo to library only if it wasnt already saved i.e. its just been taken
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 have tried by doing this below code, but i don't know where it is saving images to the App resource in 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 appreciated. Thanks for the help!