Symbole introuvable: kUTTypeImage

J'ai copié quelques bouts de code à partir de la documentation d'apple- et j'ai eu ces 2 erreurs:

Undefined symbols for architecture i386:
  "_kUTTypeImage", referenced from:
      -[ImagePicker imagePickerController:didFinishPickingMediaWithInfo:] in ImagePicker.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Ce que je fais mal?

Modifier: Le code:

- (IBAction) showSavedMediaBrowser {
    [self startMediaBrowserFromViewController: self
                                usingDelegate: (id)self];
}

- (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller
                               usingDelegate: (id <UIImagePickerControllerDelegate,
                                               UINavigationControllerDelegate>) delegate {

    if (([UIImagePickerController isSourceTypeAvailable:
          UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
        || (delegate == nil)
        || (controller == nil))
        return NO;

    UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
    mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

    // Displays saved pictures and movies, if both are available, from the
    // Camera Roll album.
    mediaUI.mediaTypes =
    [UIImagePickerController availableMediaTypesForSourceType:
     UIImagePickerControllerSourceTypeSavedPhotosAlbum];

    // Hides the controls for moving & scaling pictures, or for
    // trimming movies. To instead show the controls, use YES.
    mediaUI.allowsEditing = YES;

    mediaUI.delegate = delegate;

    [controller presentViewController:mediaUI animated:YES completion:nil];
    return YES;
}

- (void) imagePickerController: (UIImagePickerController *) picker
 didFinishPickingMediaWithInfo: (NSDictionary *) info {

    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
    UIImage *originalImage, *editedImage, *imageToUse;

    // Handle a still image picked from a photo album
    if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeImage, 0)
        == kCFCompareEqualTo) {

        editedImage = (UIImage *) [info objectForKey:
                                   UIImagePickerControllerEditedImage];
        originalImage = (UIImage *) [info objectForKey:
                                     UIImagePickerControllerOriginalImage];

        if (editedImage) {
            imageToUse = editedImage;
        } else {
            imageToUse = originalImage;
        }
        // Do something with imageToUse
    }

    [[picker parentViewController] dismissModalViewControllerAnimated: YES];
}

Je pense que l'erreur est l'endroit où la dernière méthode commence, mais je ne suis pas sûr.

Votre message n'a pas beaucoup de contexte pour expliquer les sections de code; Veuillez expliquer votre scénario plus clairement.

69
demandé sur CodeBender 2012-04-13 20:47:30

2 réponses

Recherchez le symbole (kUTTypeImage) et recherchez l'image/la bibliothèque dans laquelle il devrait exister (MobileCoreServices.framework dans ce cas). Ensuite, liez votre binaire avec ce framework.

182
répondu justin 2013-04-28 06:03:24

Réponse rapide obligatoire:

import MobileCoreServices
16
répondu CodeBender 2016-07-24 22:49:05