ComputedProperty(indexingKey:)
A macro that creates a computed property for an AppEntity that allows for providing a get and/or set accessor
Declaration
@attached(peer, names: prefixed(`$`), prefixed(`_`)) @attached(accessor, names: named(get), named(set)) macro ComputedProperty(indexingKey: PartialKeyPath<CSSearchableItemAttributeSet>)Parameters
- indexingKey:
A Spotlight attribute set key mapping for this property.
Mentioned in
Overview
Deferred properties have a few trade offs to consider:
They are not included when indexing and IndexedEntity
They are not sent to Shortcuts and Siri automatically and will only be fetched when needed
Example
struct Restaurant: AppEntity {
var model: Menu
@ComputedProperty(indexingKey: \.displayName)
var menuItems: [MenuItem] {
model.menuItems
}
}