swiftuidocumentgroup

What is the difference between `FileDocument` and `ReferenceFileDocument` for `DocumentGroups` in SwiftUI?


I'm trying to setup a DocumentGroup in my app, but there's no examples out there yet ReferenceFileDocument is for. I know what a FileDocument is, but how are ReferenceFileDocuments different.

In the docs all it says is:

Conformance to ReferenceFileDocument is expected to be thread-safe, and deserialization and serialization will be done on a background thread.


Solution

  • ReferenceFileDocument is a document type that will auto-save in the background. It is notified of changes via the UndoManager, so in order to use it you must also make your document undo-able.

    The only mention I see of it in the docs is here.

    Here is a working example.