Instance Method インスタンスメソッド

fileExporter(isPresented:document:contentType:defaultFilename:onCompletion:)

Presents a system interface for allowing the user to export an in-memory document to a file on disk. あるインメモリ書類をディスク上のファイルにエクスポートすることをユーザに許可するためのシステムインターフェイスを提示します。

Declaration 宣言

func fileExporter<D>(isPresented: Binding<Bool>, document: D?, contentType: UTType, defaultFilename: String? = nil, onCompletion: @escaping (Result<URL, Error>) -> Void) -> some View where D : ReferenceFileDocument

Parameters パラメータ

isPresented

A binding to whether the interface should be shown. インターフェイスが示されるべきかどうかへのあるバインディング。

document

The in-memory document to export. エクスポートするインメモリ書類。

contentType

The content type to use for the exported file. エクスポートされたファイルに対して使用する内容型。

defaultFilename

If provided, the default name to use for the exported file, which will the user will have an opportunity to edit prior to the export. 提供されたならば、エクスポートされたファイルに対して使用する省略時の名前、それはユーザがエクスポートの前に編集する機会を持つでしょう。

onCompletion

A callback that will be invoked when the operation has has succeeded or failed. あるコールバック、それは操作が成功したまたは失敗した時に発動されます。

result 結果

A Result indicating whether the operation succeeded or failed. あるResult、操作が成功したか失敗したかを指し示しています。

Discussion 議論

In order for the interface to appear, both isPresented must be true and document must not be nil. 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. インターフェイスが現れるようにするために、isPresentedtrueでなければならない、そしてdocumentnilであってはならない、両方が必要です。操作が終了した場合、isPresentedfalseに設定されるでしょう、onCompletionが呼び出される前に。ユーザが操作を取り消すならば、isPresentedfalseに設定されます、そしてonCompletionは呼び出されません。

The contentType provided must be included within the document type’s writableContentTypes, otherwise the first valid writable content type will be used instead. 提供されたcontentTypeは、書類型のもつwritableContentTypes内に含まれなければなりません、そうでなければ最初の有効な書き出し可能な内容型が代わりに使われるでしょう。

See Also 参照

File Managers