Function

LSCopyDefaultRoleHandlerForContentType(_:_:)

Returns the application bundle identifier of the user’s preferred default handler for the specified content type with the specified role.

Declaration

func LSCopyDefaultRoleHandlerForContentType(_ inContentType: CFString, _ inRole: LSRolesMask) -> Unmanaged<CFString>?

Parameters

inContentType

The content type. The content type is a uniform type identifier (UTI).

inRole

The role. Pass kLSRolesAll if any role is acceptable. For additional possible values, see LSRolesMask.

Return Value

The application bundle identifier of the default handler for the specified content type in the specified roles, or NULL if no handler is available.

Discussion

This function returns the user’s currently preferred default handler for the specified content type. Say, for example, that LSSetDefaultRoleHandlerForContentType(_:_:_:) has been used to set “com.Apple.TextEdit” for the “public.xml” content type. When a file whose content type is “public.xml” is double-clicked, TextEdit will be launched to open the file. If you call LSCopyDefaultRoleHandlerForContentType (CFSTR(“public.xml”), kLSRolesAll), the string com.apple.TextEdit is returned.

The CFBundleDocumentTypes key in an application’s Info.plist can be used to set an application’s content handling capabilities. The LSItemContentTypes key is particularly useful because it supports the use of UTIs in document claims. For information on the CFBundleDocumentTypes key, see the section “CFBundleDocumentTypes” in macOS Runtime Configuration Guidelines.

Version-Notes

Thread-safe since OS X v10.4.

See Also

Working With Role Handlers

func LSCopyAllRoleHandlersForContentType(CFString, LSRolesMask) -> Unmanaged<CFArray>?

Locates an array of application bundle identifiers for applications capable of handling a specified content type with the specified roles.

func LSSetDefaultRoleHandlerForContentType(CFString, LSRolesMask, CFString) -> OSStatus

Sets the user’s preferred default handler for the specified content type in the specified roles.

func LSGetHandlerOptionsForContentType(CFString!) -> LSHandlerOptions

Gets the handler options for the specified content type.

Deprecated
func LSSetHandlerOptionsForContentType(CFString!, LSHandlerOptions) -> OSStatus

Sets the handler option for the specified content type.

Deprecated
func LSCopyAllHandlersForURLScheme(CFString) -> Unmanaged<CFArray>?

Locates application bundle identifiers for applications capable of handling the specified URL scheme.

Deprecated
func LSCopyDefaultHandlerForURLScheme(CFString) -> Unmanaged<CFString>?

Returns the application bundle identifier of the user’s preferred default handler for the specified URL scheme.

Deprecated
func LSSetDefaultHandlerForURLScheme(CFString, CFString) -> OSStatus

Sets the user’s preferred default handler for the specified URL scheme.