Contents

init(exporting:)

Creates a value representation that exports an entity to a system intent value.

Declaration

init(exporting: @escaping  @Sendable (Item) async throws -> IntentValue)

Parameters

  • exporting:

    A closure that converts an entity to a system intent value. This closure is called when the system needs to transfer your entity across process boundaries or export it for use by other apps or system features.

Discussion

Use this initializer when you only need to export your entity to a system type, without supporting import back into your entity type.

Example

struct VenueEntity: AppEntity, Transferable {
    static var transferRepresentation: some TransferRepresentation {
        IntentValueRepresentation(
            exporting: { entity in
                PlaceDescriptor(
                    representations: [
                        .address(entity.address),
                        .coordinate(.init(
                            latitude: entity.latitude,
                            longitude: entity.longitude
                        ))
                    ],
                    commonName: entity.name
                )
            }
        )
    }
}