Search code examples
ioscocoa-touchmobilecoreservices

Use of undeclared identifier 'kUTTypeMovie'


I am getting the error message - Use of undeclared identifier 'kUTTypeMovie'

in the below code -

-(IBAction)selectVideo:(id)sender {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];

    imagePicker.delegate = self;
    [self presentModalViewController:imagePicker animated:YES];
}

What's wrong with it?


Solution

  • You have to add the framework MobileCoreServices to the project, and then import it:

    Objective C:

    #import <MobileCoreServices/MobileCoreServices.h>
    

    That will make the problem go away.

    Swift 4:

    import MobileCoreServices