---
title: "LSCopyDefaultRoleHandlerForContentType(_:_:)"
framework: coreservices
role: symbol
role_heading: Function
path: coreservices/1449868-lscopydefaultrolehandlerforconte
---

# LSCopyDefaultRoleHandlerForContentType(_:_:)

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

## Declaration

```swift
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 doc://com.apple.documentation/documentation/coreservices/lsrolesmask.

## Return Value

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

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

- [LSCopyAllRoleHandlersForContentType(_:_:)](coreservices/1448020-lscopyallrolehandlersforcontentt.md)
- [LSSetDefaultRoleHandlerForContentType(_:_:_:)](coreservices/1444955-lssetdefaultrolehandlerforconten.md)
- [LSSetDefaultHandlerForURLScheme(_:_:)](coreservices/1447760-lssetdefaulthandlerforurlscheme.md)
- [LSRolesMask](coreservices/lsrolesmask.md)
