Contents

init(exporting:)

Creates a value representation that exports an entity to an IntentPerson.

Declaration

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

Parameters

  • exporting:

    A closure that converts an entity to an IntentPerson. 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 an IntentPerson, without supporting import back into your entity type.

Example

struct ContactEntity: AppEntity, Transferable {
    static var transferRepresentation: some TransferRepresentation {
        IntentValueRepresentation(
            exporting: { entity in
                IntentPerson(
                    identifier: .applicationDefined(entity.id),
                    name: .displayName(entity.name),
                    handle: .init(emailAddress: entity.email)
                )
            }
        )
    }
}