Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 767
Ashish Agarwal Avatar asked Oct 11 '22 01:10

Ashish Agarwal


Video Answer


3 Answers

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
like image 51
The dude Avatar answered Oct 19 '22 15:10

The dude


swift

import MobileCoreServices

objective c

#import <MobileCoreServices/MobileCoreServices.h>
like image 31
budiDino Avatar answered Oct 19 '22 13:10

budiDino


I am a novice at iOS development and xcode and spent some time trying to find out why just the import was not working. After figuring out the problem with a more experienced member of my team I found out that not only must you include

#import <MobileCoreServices/MobileCoreServices.h>

but you must also link binaries to the library of the MobileCoreServices framework to the build phases of your project.

Hope this helps! I sure needed this info when I was doing this.

like image 33
Josh Lowe Avatar answered Oct 19 '22 13:10

Josh Lowe