Contents

callAsFunction(_:)

Presents a new document window.

Declaration

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

Parameters

  • newDocument:

    The new file document to present.

Discussion

Don’t call this method directly. SwiftUI calls it when you call the newDocument action:

newDocument(TextDocument(text: selectedText))

For information about how Swift uses the callAsFunction() method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language.

See Also

Calling the action