Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

UIImagePickerControllerMediaUrl

So I'm doing the tutorial on how to create the message application.

I am now at the point were we are adding the camera features.

But, I get a problem here in my CameraViewController.m

else {
    // A video was taken/selected!
    self.videoFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
} <<<< Implicit conversion of C pointer type 'CGPathRef' (aka 'const struct CGPath *') to Objective-C pointer type 'NSString *' requires a bridged cast

I have the property in my .h file I checked that.

4 Answers

see the teachers notes in this video. in short replace:

self.videoFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path]

with

NSURL *imagePickerURL = [info objectForKey:UIImagePickerControllerMediaURL]; 
self.videoFilePath = [imagePickerURL path];

Can you add the whole if/else statement please.

My CamerViewController.m

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
    // A photo was taken/selected!
    self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
        // save the image!
        UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
    }
    [self dismissViewControllerAnimated:YES completion:nil];
}
else {
    // A video was taken/selected!
    self.videoFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
}

}

My CamerViewController.h

@interface CameraViewController : UITableViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

@property (nonatomic, strong) UIImagePickerController *imagePicker; @property (nonatomic, strong) UIImage *image; @property (nonatomic, strong) NSString *videoFilePath;

When I type the "path];" it doesn't come up as showing it is a NSString? Is that the problem? It shows it as "CGPathRef"

When I type the "path];" it doesn't come up as showing it is a NSString? Is that the problem? It shows it as "CGPathRef"