<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DocumentGroup/init(viewing:contentType:viewer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13DocumentGroupV01_a5Data_aB0AD05ModelC0VRszrlE7viewing11contentType6viewerACyAFq_G0aE0010PersistentF0_pXp_07UniformI11Identifiers6UTTypeVq_yctcfc::OverloadGroup"
  },
  "title" : "init(viewing:contentType:viewer:)"
}
-->

# init(viewing:contentType:viewer:)

Instantiates a document group for viewing
documents that store a specific model type.

```
nonisolated init(viewing modelType: any PersistentModel.Type, contentType: UTType, viewer: @escaping () -> Content)
```

## Parameters

`modelType`

The model type defining the schema used for each document.

`contentType`

The content type of document your app can view.
It should conform to `UTType.package`.

`viewer`

The viewing UI for the provided document.

## Discussion

```
 @main
 struct Todo: App {
     var body: some Scene {
         DocumentGroup(viewing: TodoItem.self, contentType: .todoItem) {
             ContentView()
         }
     }
 }

 extension UTType {
     static var todoItem = UTType(exportedAs: "com.myApp.todoItem")
 }
```

> Important: If your app declares custom uniform type identifiers,
> include corresponding entries in the app’s `Info.plist`.
> For more information, see <doc://com.apple.documentation/documentation/UniformTypeIdentifiers/defining-file-and-data-types-for-your-app>.
> Also, remember to specify the supported Document types in the `Info.plist` as well.

---

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)