Contents

callAsFunction(_:)

Presents a new document window for the in-memory document returned by the provided closure.

Declaration

@MainActor @preconcurrency func callAsFunction<D>(_ newDocument: @autoclosure  @escaping  @Sendable () -> sending  D) where D : ReadableDocument

Parameters

  • newDocument:

    A closure that produces the in-memory document to present.

Discussion

Don’t call this method directly. SwiftUI calls it when you call the newDocument action with a ReadableDocument factory.

The factory closure runs when SwiftUI needs the document instance. SwiftUI then injects the instance into the matching DocumentGroup and presents its window. The matching document group is the first creatable group whose readable content types overlap with D.readableContentTypes.

See Also

Calling the action