Contents

LSCopyDefaultRoleHandlerForContentType(_:_:)

Returns the 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.

  • inRole:

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

Return Value

The 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 app’s Info.plist can be used to set an app’s content handling capabilities. The LSItemContentTypes key is particularly useful because it supports the use of UTIs in document claims.

Version-Notes

Thread-safe since OS X v10.4.

See Also

Working with Role Handlers