Contents

displayName(forType:)

Returns the descriptive name for the specified document type, which is used in the File Format pop-up menu of the Save As dialog.

Declaration

func displayName(forType typeName: String) -> String?

Parameters

  • typeName:

    The name of a document type, specified by CFBundleTypeName in the application’s Info.plist file.

Return Value

The descriptive name for the document type specified by documentTypeName. If there is no descriptive name, returns documentTypeName.

Discussion

For a document-based application, supported document types are specified in the Info.plist file by the CFBundleDocumentTypes array. Each document type is specified by a dictionary in this array, and is named by the CFBundleTypeName attribute. You can provide a descriptive, localized, representation of this name by providing a corresponding entry in the InfoPlist.strings file(s). For example, given an Info.plist file that contains the following fragment:

<dict>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>BinaryFile</string>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>binary</string>
            </array>

you could provide a descriptive name by adding an entry in the InfoPlist.strings file:

BinaryFile = "Binary file format";

See Also

Managing Document Types