Contents

creationSource

The source associated with the button that created this document.

Declaration

@MainActor final var creationSource: DocumentCreationSource? { get }

Discussion

On iOS, you can specify the source via a NewDocumentButton in DocumentGroupLaunchScene:

extension DocumentCreationSource {
    static let scanner: Self =
        DocumentCreationSource(id: "document-from-scanner")

    static let template: Self =
        DocumentCreationSource(id: "document-from-template")
}

DocumentGroupLaunchScene("Documents") {
    NewDocumentButton("Scan Document", source: .scanner)
    NewDocumentButton("New from Template", source: .template)
}

Use this property to determine which NewDocumentButton triggered the creation of the current document, allowing you to customize the UI accordingly.

See Also

Accessing document properties