Contents

AppEntity.ValueRepresentation

A type alias for IntentValueRepresentation, providing a convenient way to define transfer representations that convert between app entities and system intent values.

Declaration

typealias ValueRepresentation = IntentValueRepresentation

Discussion

Use ValueRepresentation in your entity’s transferRepresentation to enable bidirectional conversion with system types like IntentPerson, PlaceDescriptor, and other _SystemIntentValue types.

Example

struct ContactEntity: AppEntity, Transferable {
    static var transferRepresentation: some TransferRepresentation {
        ValueRepresentation(
            exporting: { entity in
                IntentPerson(
                    name: .displayName(entity.name),
                    handle: .init(emailAddress: entity.email)
                )
            },
            importing: { person in
                ContactEntity(
                    name: person.name.displayString,
                    email: person.handle?.value ?? ""
                )
            }
        )
    }
}