swiftmacoscocoalaunch-services

All Application URLs for MIME type


Besides LSCopyDefaultApplicationURLForURL there exists LSCopyApplicationURLsForURL to get all applications, not just the default one.

If you just want to get default applications for a MIME type, there is LSCopyDefaultApplicationURLForContentType, but it doesn't seem to have an equivalent to get all supported applications.

How can I get all supported applications for a MIME type, without having an actual file on disk?


Solution

  • The LSCopyAllRoleHandlersForContentType will return a list of application bundle IDs that are registered to handle a particular content type (using a UTI).

    The logical difference between this function and LSCopyApplicationURLsForURL is that the list can be filtered to just those applications that handle said content in a particular way (display-only, edit, etc.). If you want all of the applications, pass kLSRolesAll.

    To obtain the actual application URL(s), call LSCopyApplicationURLsForBundleIdentifier with one of the returned app IDs.