One Logo Pool Ball
CoreTransferable · IOS API REFERENCE

ProxyRepresentation

struct · iOS 16.0+ · SDK 27.1

struct ProxyRepresentation<Item, ProxyRepresentation> where Item : Transferable, ProxyRepresentation : Transferable

A transfer representation that uses another type's transfer representation as its own. Use this representation to rely on an existing transfer representation that's suitable for the type. For example, a `Note` type might use the <doc://com.apple.documentation/documentation/Swift/String> structure's built-in ``Transferable`` conformance --- a plain text representation --- so it can be pasted into any text editor: struct Note: Transferable { var body: String static var transferRepresentation: some TransferRepresentation { ProxyRepresentation(\.body) } } `ProxyRepresentation` makes it easy to provide alternative representations for receivers that don't support the preferred custom format. struct Todo: Transferable, Codable { var text: String var isDone = false static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .todo) ProxyRepresentation(\.text) } } extension UTType { static let todo = UTType(exportedAs: "com.example.todo") } Write the order of the representations in the `transferRepresentation` property from more preferred to less preferred. In the previous example, if the receiver knows about the custom `com.example.todo` content type, it will receive that custom content type. Using a `ProxyRepresentation` as the alternative lets people paste the to-do item in any text editor that doesn't support the `com.example.todo` content type but works with text formats. `ProxyRepresentation` is a convenience, and its evaluation isn't supposed to be calculation-heavy. Don't perform long-running work in `exporting` and `importing` closures. They shouldn't contain network requests, file operations, or other potentially time-consuming tasks as they can cause delays during operations with `Transferable` items. Use <doc://com.apple.documentation/documentation/coretransferable/filerepresentation> or <doc://com.apple.documentation/documentation/coretransferable/datarepresentation> to read and write files or for other lengthy tasks.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ProxyRepresentation.init(importing:)

synchronous callback requires a nonescaping JS-thread call

ProxyRepresentation.init(exporting:)

synchronous callback requires a nonescaping JS-thread call

ProxyRepresentation.init(exporting:importing:)

synchronous callback requires a nonescaping JS-thread call

ProxyRepresentation.init(exporting:importing:)

synchronous callback requires a nonescaping JS-thread call

All CoreTransferable types →