Initializer

init(viewing:viewer:)

Creates a document group capable of viewing file documents.

Declaration 宣言

init(viewing documentType: Document.Type, viewer: @escaping (FileDocumentConfiguration<Document>) -> Content)
Available when Document conforms to FileDocument and Content conforms to View. DocumentFileDocumentに準拠する、そしてContentViewに準拠する場合に利用可能です。

Parameters パラメータ

documentType

The type of document your app can view.

viewer

The viewing UI for the provided document. 提供された書類に対する視聴UI。

Discussion 議論

Use this method to create a document group that can view files of a specific type. The example below creates a new document viewer for MyImageFormatDocument and displays them with MyImageFormatViewer:


@main
struct MyApp: App {
    var body: some Scene {
        DocumentGroup(viewing: MyImageFormatDocument.self) { file in
            MyImageFormatViewer(image: file.document)
        }
    }
}

You tell the system about the app’s role with respect to the document type by setting the CFBundleTypeRole Info.plist key with a value of Viewer.

See Also 参照

Creating a Document Group 書類グループを作成する