fileWrapper(configuration:)
Serializes a document snapshot to a file wrapper.
Declaration
func fileWrapper(configuration: Self.WriteConfiguration) throws -> FileWrapperParameters
- configuration:
Information about a file that already exists for the document, if any.
Return Value
The destination to serialize the document contents to. The value can be a newly created FileWrapper or an update of the one provided in the configuration input.
Discussion
To store a document — for example, in response to a Save command — SwiftUI calls this method. Use it to serialize the document’s data and create or modify a file wrapper with the serialized data:
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
let data = try JSONEncoder().encode(model)
return FileWrapper(regularFileWithContents: data)
}