Contents

FileDocument

A type that you use to serialize documents to and from file.

Declaration

@preconcurrency protocol FileDocument : Sendable

Overview

To store a document as a value type — like a structure — create a type that conforms to the FileDocument protocol and implement the required methods and properties. Your implementation:

Ensure that types that conform to this protocol are Sendable. In particular, SwiftUI calls the protocol’s methods from different isolation domains. Don’t perform serialization and deserialization on MainActor.

Topics

Reading a document

Writing a document

See Also

Storing document data in a structure instance