Contents

init(importedAs:conformingTo:)

Creates a type your app uses, but doesn’t own, based on an identifier and a supertype that it conforms to.

Declaration

init(importedAs identifier: String, conformingTo parentType: UTType? = nil)

Parameters

  • identifier:

    The identifier of your type.

  • parentType:

    A type to extend with this type.

Discussion

Define a type with this initializer when you’re supporting a type that another app owns. For example, the following code uses another app’s type information to open or save files in its app:

extension UTType {
    /// The type of a supported file format.
    public static var anotherFormat: UTType {
        UTType(importedAs: "com.example.anotherformat")
    }
}

See Also

Creating a type