Contents

suggestedFileName(_:)

Provides a filename to use if the receiver chooses to write the item to disk.

Declaration

func suggestedFileName(_ fileName: @escaping  @Sendable (Self.Item) -> String?) -> some TransferRepresentation<Self.Item>

Parameters

  • fileName:

    The optional closure that returns the suggested filename including the filename extension. If several suggested file names are specified on an item, only the last one will be used.

Discussion

Any transfer representation can be written to disk.

struct Note: Transferable {
    var title: String
    var body: String
    static var transferRepresentation: some TransferRepresentation {
        ProxyRepresentation(exporting: \.body)
            .suggestedFileName { $0.title + ".txt" }
     }
 }