fileExporter(isPresented:documents:contentType:onCompletion:)
Presents a system interface for exporting a collection of value type documents to files on disk.
Declaration
nonisolated func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentType: UTType, onCompletion: @escaping (Result<[URL], any Error>) -> Void) -> some View where C : Collection, C.Element : FileDocument
Parameters
- isPresented:
A binding to whether the interface should be shown.
- documents:
The collection of in-memory documents to export.
- contentType:
The content type to use for the exported file.
- onCompletion:
A callback that will be invoked when the operation has has succeeded or failed.
- result
A
Resultindicating whether the operation succeeded or failed.
Discussion
In order for the interface to appear, both isPresented must be true and documents must not be empty. When the operation is finished, isPresented will be set to false before onCompletion is called. If the user cancels the operation, isPresented will be set to false and onCompletion will not be called.
The contentType provided must be included within the document type’s writableContentTypes, otherwise the first valid writable content type will be used instead.
See Also
Exporting to file
fileExporter(isPresented:document:contentType:defaultFilename:onCompletion:)fileExporter(isPresented:document:contentTypes:defaultFilename:onCompletion:onCancellation:)fileExporter(isPresented:documents:contentTypes:onCompletion:onCancellation:)fileExporter(isPresented:item:contentTypes:defaultFilename:onCompletion:onCancellation:)fileExporter(isPresented:items:contentTypes:onCompletion:onCancellation:)fileExporterFilenameLabel(_:)