Contents

LSGetApplicationForInfo(_:_:_:_:_:_:)

Locates the preferred app for opening items with a specified file type, creator signature, filename extension, or any combination of these characteristics.

Declaration

func LSGetApplicationForInfo(_ inType: OSType, _ inCreator: OSType, _ inExtension: CFString!, _ inRoleMask: LSRolesMask, _ outAppRef: UnsafeMutablePointer<FSRef>!, _ outAppURL: UnsafeMutablePointer<Unmanaged<CFURL>?>!) -> OSStatus

Parameters

  • inType:

    The file type to consider. Comparison of file types is case-sensitive. Pass kLSUnknownType if the items’ file type is unimportant.

  • inCreator:

    The creator signature to consider. Comparison of creator signatures is case-sensitive. Pass kLSUnknownCreator if the items’ creator signature is unimportant.

  • inExtension:

    A Core Foundation string object specifying the filename extension to consider; see the CFString Reference in the Core Foundation Reference Documentation for a description of the CFStringRef data type. Comparison of filename extensions is case-insensitive. Pass NULL if the items’ filename extension is unimportant.

  • inRolesMask:

    A bit mask specifying the application’s desired role or roles with respect to items with the specified characteristics; see Lsrolesmask for a description of this mask. If the role is unimportant, pass kLSRolesAll.

  • outAppRef:

    A pointer to a file-system reference that, on return, will identify the preferred application for opening items with the specified characteristics; see the File Manager Reference in the Carbon File Management Documentation for a description of the FSRef data type. Pass NULL if you are not interested in identifying the preferred application in this form; however, this parameter and outAppURL cannot both be NULL.

  • outAppURL:

    A pointer to a Core Foundation URL reference that, on return, will identify the preferred application for items with the specified characteristics; see the CFURL Reference in the Core Foundation Reference Documentation for a description of the CFURLRef data type. Pass NULL if you are not interested in identifying the preferred application in this form; however, this parameter and outAppRef cannot both be NULL.

    Despite the absence of the word Copy in 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 items with the specified characteristics is found in the Launch Services database, the function will return the result code kLSApplicationNotFoundErr.

Discussion

You can request any combination of one, two, or all three of the characteristics specified by the inType, inCreator, and inExtension parameters; at least one of these characteristics must be supplied. Note that since the choice of a preferred application is subject to any document binding preferences the user may have set, the application chosen will not necessarily be the default application that matches the input characteristics, but may instead be a user-specified application that overrides the default.

Version-Notes

Thread-safe since Mac OS version 10.2.

See Also

Deprecated Functions