Search code examples
cocoafile-typeuti

Testing if an application can open a specific type?


On Mac OS X, how can I tell if a given application opens a specific type?

I have two UTIs that I'm interested in: public.text and public.image and I have a list of applications. I want to filter the list by those two types so I have a list of text viewers and a list of image viewers.

I've seen a related question on SO where it's possible to get a list of all the viewers for a particular document type. I could do that and get the intersection of the set, but I'd rather be able to ask each application individually.

Are there any Cocoa or Carbon calls for that?


Solution

  • If you want a list of applications for a given document type, use LSCopyAllRoleHandlersForContentType.

    If you want a list of document types for a specific application, open the application's Info.plist file and read the CFBundleDocumentTypes key.