how get UIImagePickerControllerReferenceURL camera

camera, iphone, objective-c, save, uiimagepickercontroller

Solution

If you capture a video, the media is saved on device's storage, and you can access its URL. If you capture an image, the media is saved into device's memory, and you can access its raw data.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    NSLog(@"%@", info);

    // An image
    if([info[UIImagePickerControllerMediaType] isEqualToString:@"public.image"])
        UIImage *image=info[UIImagePickerControllerOriginalImage];

    // A video
    else
        NSURL *url=info[UIImagePickerControllerMediaURL]];
}

EDIT: you asked why an image's URL is nil. As you can see, a captured image is never saved on device's storage. One advantage to have picture in memory is that you can process it before storing it on device or sending it over a network.

Problem

I'm saving an image from the iPhone camera and I manage the delegate method: ``` - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info ``` here I need to know: ``` [info objectForKey:UIImagePickerControllerReferenceURL] ``` but it is always nil if I just took a picture, if different from nil load a picture from the camera roll. Why is that?

Original source