TransferRepresentation
A declarative description of the process of importing and exporting a transferable item.
Declaration
protocol TransferRepresentation<Item> : SendableOverview
Combine multiple existing transfer representations to compose a single transfer representation that describes how to transfer an item in multiple scenarios.
The following shows a Greeting type that transfers both as a Codable type and by proxy through its message string.
import UniformTypeIdentifiers
struct Greeting: Codable, Transferable {
let message: String
var displayInAllCaps: Bool = false
static var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .greeting)
ProxyRepresentation(exporting: \.message)
}
}
extension UTType {
static let greeting = UTType(exportedAs: "com.example.greeting")
}