init(viewing:contentType:viewer:)
Instantiates a document group for viewing documents that store a specific model type.
Declaration
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")
}