for an app I'm developing, I use UIImagePickerController to shoot a picture and store it in camera roll:
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
//... some stuff ...
UIImageWriteToSavedPhotosAlbum([info objectForKey:@"UIImagePickerControllerOriginalImage"], nil, nil, nil);
}
the image is saved, now I need to get its reference url so I try to enumerate camera roll and get the last image, but I always get the image before the one I just shot.
Anybody has an idea how to get the reference of the just saved picture?
Thanks, Max
This solution should fix the problem:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:((UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage]).CGImage
metadata:[info objectForKey:UIImagePickerControllerMediaMetadata]
completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"assetURL %@", assetURL);
}];
et voila:
assetURL assets-library://asset/asset.JPG?id=1611E84C-24E2-4177-B49A-1C57B4A9C665&ext=JPG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With