<!--
{
  "availability" : [
    "iOS: 14.0.0 - 27.0.0",
    "iPadOS: 14.0.0 - 27.0.0",
    "macCatalyst: 14.0.0 - 27.0.0",
    "macOS: 11.0.0 - 27.0.0",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DocumentGroup/init(newDocument:editor:)-1mltk",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13DocumentGroupVA2A013ReferenceFileC0RzrlE03newC06editorACyxq_Gxyc_q_AA0efC13ConfigurationVyxGctcfc"
  },
  "title" : "init(newDocument:editor:)"
}
-->

# init(newDocument:editor:)

Creates a document group that is able to create and edit reference file
documents.

```
@preconcurrency nonisolated init(newDocument: @escaping @Sendable () -> Document, @ContentBuilder editor: @escaping (ReferenceFileDocumentConfiguration<Document>) -> Content)
```

## Parameters

`newDocument`

The initial document used when the user creates
a new document. The argument should create a new instance, such that
a new document is created on each invocation of the closure.

`editor`

The editing UI for the provided document.

## Discussion

The current document for a given editor instance is also provided as an
environment object for its subhierarchy.

Undo support is not automatically provided for this construction of
a `DocumentGroup`, and any updates to the document by the editor view
hierarchy are expected to register undo operations when appropriate.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)