I've implemented the delegate method and can get access to the picked UIImage, like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *pickedImage = [info valueForKey:UIImagePickerControllerOriginalImage];
I want to save it to a directory, but I need a file name. So rather than just picking a random file name it would make sense to pick the same file name as the image.
Is there a way to retrieve it from that info dictionary?
Use the code below
You could use the
UIImagePickerControllerReferenceURL
value of the info dictionary instead of theUIImagePickerControllerOriginalImage
. This should give you the URL to the original media item.This would return you a
NSURL
object which you then can use to build your new filename from.