views:

25

answers:

2

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?

A: 

Launch Services is your friend. But I don't think there's any API which gets the UTIs supported by a given app, so I would suggest you to use what you already described, unfortunately.

Yuji
+2  A: 

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.

Darren
Pitfall: CFBundleDocumentTypes dictionaries won't always have a list of content types. In that case, you'll have to go through each dictionary's other types (filename extensions, OSTypes, etc.) and look up the UTIs for them.
Peter Hosey

related questions