IntentValueRepresentation
A transfer representation that enables bidirectional conversion between app entities and system intent values.
Declaration
struct IntentValueRepresentation<Item, IntentValue> where Item : Transferable, IntentValue : _IntentValue, IntentValue : SendableMentioned in
Overview
IntentValueRepresentation bridges the gap between your custom AppEntity types and system-provided intent values (like IntentPerson, PlaceDescriptor, and other _SystemIntentValue types).
Export and Import
You can create a representation that supports export only, or both export and import:
// Export only
ValueRepresentation(
exporting: { entity in
IntentPerson(name: .displayName(entity.name))
}
)
// Bidirectional
ValueRepresentation(
exporting: { entity in
IntentPerson(name: .displayName(entity.name))
},
importing: { person in
ContactEntity(name: person.name.displayString)
}
)Key Path-Based Export
For entities that directly contain a system intent value property, you can use a simplified key path syntax:
struct LocationEntity: TransientAppEntity, Transferable {
@Property
var place: PlaceDescriptor
static var transferRepresentation: some TransferRepresentation {
ValueRepresentation(exporting: \.place)
}
}