For future reference, I was interested specifically in getting a list of applications that are capable of opening a particular document type. The accepted answer pointed in the right direction but was not a complete solution as LSCopyApplicaionURLsForURL
and its sibling LSCopyAllRoleHandlersForContentType
return a bundle identifier, not the application itself. Therefore I still needed the application's:
- Path
- Display Name; and
- Icon
Below is the code I've used to retrieve all of that information:
NSArray* handlers = LSCopyAllRoleHandlersForContentType(@"com.adobe.pdf", kLSRolesAll);
for (NSString* bundleIdentifier in handlers) {
NSString* path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier: bundleIdentifier];
NSString* name = [[NSFileManager defaultManager] displayNameAtPath: path];
NSImage* icon = [[NSWorkspace sharedWorkspace] iconForFile: path];
}