<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreTransferable",
  "identifier" : "/documentation/CoreTransferable/Transferable",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Core Transferable"
    ],
    "preciseIdentifier" : "s:16CoreTransferable0B0P"
  },
  "title" : "Transferable"
}
-->

# Transferable

A protocol that describes how a type interacts with transport APIs
such as drag and drop or copy and paste.

```
@preconcurrency protocol Transferable : Sendable
```

## Overview

To conform to the [`Transferable`](/documentation/CoreTransferable/Transferable) protocol,
implement the [`transferRepresentation`](/documentation/CoreTransferable/Transferable/transferRepresentation) property.
For example, an image editing app’s layer type might
conform to `Transferable` to let people drag and drop image layers
to reorder them within a document.

```
struct ImageDocumentLayer {
    init(data: Data) { }
    func data() -> Data { Data() }
    func pngData() -> Data { Data() }
}
```

The following shows how you can extend `ImageDocumentLayer`  to
conform to `Transferable`:

```
extension ImageDocumentLayer: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        DataRepresentation(contentType: .layer) { layer in
            layer.data()
        } importing: { data in
            ImageDocumentLayer(data: data)
        }
        DataRepresentation(exportedContentType: .png) { layer in
            layer.pngData()
        }
    }
}
```

When people drag and drop a layer within the app or onto another app
that recognizes the custom `layer` content type,
the app uses the first representation.
When people drag and drop the layer onto a different image editor,
it’s likely that the editor recognizes the PNG file type.
The second transfer representation adds support for PNG files.

The following declares the custom `layer` uniform type identifier:

```
extension UTType {
    static let layer = UTType(exportedAs: "com.example.layer")
}
```

> Important: If your app declares custom uniform type identifiers,
> include corresponding entries in the app’s `Info.plist`.
> For more information, see <doc://com.apple.documentation/documentation/UniformTypeIdentifiers/defining-file-and-data-types-for-your-app>.

If one of your existing types conforms to <doc://com.apple.documentation/documentation/Swift/Codable>,
`Transferable` automatically handles conversion to and from `Data`.
The following declares a simple `Note` structure that’s `Codable`
and an extension to make it `Transferable`:

```
struct Note: Codable {
    let title: String
    let body: String
}

extension Note: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        CodableRepresentation(contentType: .note)
    }
}
```

To ensure compatibility with other apps that don’t know about
the custom `note` type identifier,
the following adds an additional transfer representation
that converts the note to text.

```
extension Note: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        CodableRepresentation(contentType: .note)
        ProxyRepresentation(\.title)
    }
}
```

The order of the representations in the transfer representation matters;
place the representation that most accurately represents your type first,
followed by a sequence of more compatible
but less preferable representations.

## Topics

### Implementing a transfer representation

[`transferRepresentation`](/documentation/CoreTransferable/Transferable/transferRepresentation)

The representation used to import and export the item.

[`Representation`](/documentation/CoreTransferable/Transferable/Representation)

The type of the representation used to import and export the item.

## Relationships

### Inherits From

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)