Home > Software engineering >  What header to include to use UTType in objective c?
What header to include to use UTType in objective c?

Time:12-30

I have the following code snippet:

    NSString* filt = [NSString stringWithUTF8String:allowedExtensions[i].c_str()];
    UTType *type = [UTType typeWithIdentifier:filt];

I get the error 'Receiver 'UTType' for class message is a forward declaration'. If I'm understanding this right this means that UTType is not included properly. What file do I need to include to have it declared properly? I'm using Cocoa. I could find zero information about this through Google. I'm using Xcode 13. I'm developing for MacOS.

Stuff listed here didn't help: receiver type *** for instance message is a forward declaration

CodePudding user response:

UTType comes from a UniformTypeIdentifiers framework

@import UniformTypeIdentifiers;

or

#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

both are equivalent.

  • Related