Contents

CodableRepresentation

A transfer representation for types that participate in Swift’s protocols for encoding and decoding.

Declaration

@preconcurrency struct CodableRepresentation<Item, Encoder, Decoder> where Item : Transferable, Item : Decodable, Item : Encodable, Encoder : TopLevelEncoder, Encoder : Sendable, Decoder : TopLevelDecoder, Decoder : Sendable, Encoder.Output == Data, Decoder.Input == Data

Mentioned in

Overview

struct Todo: Codable, Transferable {
    var text: String
    var isDone = false

    static var transferRepresentation: some TransferRepresentation {
        CodableRepresentation(contentType: .todo)
    }
}

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

Topics

Creating a transfer representation

See Also

Data transfer