Contents

URLDocumentConfiguration

The configuration of an open document that stores its file URL, last modification date, and related metadata.

Declaration

@MainActor final class URLDocumentConfiguration

Overview

SwiftUI passes a URLDocumentConfiguration to the makeDocument closure of DocumentGroup. This class is @Observable — views and other observers can track changes to fileURL and other properties.

Use makeFileCoordinator() to perform coordinated reads or writes outside the normal DocumentReader/DocumentWriter flow — for example, to read a single sub-file of a package document on demand:

let coordinator = configuration.makeFileCoordinator()
var error: NSError?
coordinator.coordinate(
    readingItemAt: pageURL, options: [], error: &error
) { url in
    let data = try? Data(contentsOf: url)
    // ...
}

Topics

Accessing document properties

Coordinating file access

See Also

Storing document data in a reference type instance