LSGetApplicationForURL(_:_:_:_:)
Locates the preferred app for opening an item with a URL.
Declaration
func LSGetApplicationForURL(_ inURL: CFURL!, _ inRoleMask: LSRolesMask, _ outAppRef: UnsafeMutablePointer<FSRef>!, _ outAppURL: UnsafeMutablePointer<Unmanaged<CFURL>?>!) -> OSStatusParameters
- inURL:
A Core Foundation URL reference designating the item whose preferred application is requested; see the CFURL Reference in the Core Foundation Reference Documentation for a description of the
CFURLRefdata type. - inRolesMask:
A bit mask specifying the application’s desired role or roles with respect to the designated item; see Lsrolesmask for a description of this mask. This parameter applies only to URLs with a scheme component of
file, and is ignored for all other schemes. If the role is unimportant, passkLSRolesAll. - outAppRef:
A pointer to a file-system reference that, on return, will identify the item’s preferred application; see the File Manager Reference in the Carbon File Management Documentation for a description of the
FSRefdata type. PassNULLif you are not interested in identifying the preferred application in this form; however, this parameter andoutAppURLcannot both beNULL. - outAppURL:
A pointer to a Core Foundation URL reference that, on return, will identify the item’s preferred application; see the CFURL Reference in the Core Foundation Reference Documentation for a description of the
CFURLRefdata type. PassNULLif you are not interested in identifying the preferred application in this form; however, this parameter andoutAppRefcannot both beNULL.Despite the absence of the word
Copyin its name, this function retains the URL reference object on your behalf; you are responsible for releasing this object.
Return Value
A result code; see Result Codes. If no application suitable for opening the item is found in the Launch Services database, the function will return the result code kLSApplicationNotFoundErr.
Discussion
If the item URL’s scheme is file (designating either a file or a directory), the selection of the preferred application is based on the designated item’s filename extension, file type, and creator signature, along with the role specified by the inRolesMask parameter; otherwise, it is based on the URL scheme (such as http, ftp, or mailto).
Version-Notes
Thread-safe since Mac OS version 10.2.
See Also
Deprecated Functions
LSGetHandlerOptionsForContentType(_:)LSSetHandlerOptionsForContentType(_:_:)LSCopyAllHandlersForURLScheme(_:)LSCopyDefaultHandlerForURLScheme(_:)LSGetApplicationForItem(_:_:_:_:)LSGetApplicationForInfo(_:_:_:_:_:_:)LSCopyApplicationForMIMEType(_:_:_:)LSCanRefAcceptItem(_:_:_:_:_:)LSFindApplicationForInfo(_:_:_:_:_:)LSOpenApplication(_:_:)LSOpenItemsWithRole(_:_:_:_:_:_:_:)LSOpenURLsWithRole(_:_:_:_:_:_:)LSOpenFSRef(_:_:)LSOpenFromRefSpec(_:_:)LSCopyItemInfoForRef(_:_:_:)LSCopyItemInfoForURL(_:_:_:)LSCopyDisplayNameForRef(_:_:)LSCopyDisplayNameForURL(_:_:)LSCopyKindStringForRef(_:_:)LSCopyKindStringForURL(_:_:)LSCopyKindStringForTypeInfo(_:_:_:_:)LSCopyKindStringForMIMEType(_:_:)LSCopyItemAttribute(_:_:_:_:)LSCopyItemAttributes(_:_:_:_:)LSGetExtensionInfo(_:_:_:)LSSetExtensionHiddenForRef(_:_:)LSSetExtensionHiddenForURL(_:_:)LSRegisterFSRef(_:_:)