One Logo Pool Ball
AppIntents · IOS API REFERENCE

AppEnum

protocol · iOS 16.0+ · SDK 27.1

protocol AppEnum : AppValue, StaticDisplayRepresentable, RawRepresentable where Self.RawValue : LosslessStringConvertible

An interface to express that a custom type has a predefined, static set of values. When you want an app intent parameter or app entity property to have a fixed set of values, set the type of the underlying property to one that adopts the `AppEnum` protocol. In custom code, you use enumerations to limit the number of values available to a property of that type. For example, a fitness app might specify the available workout types using an enumeration instead of a string, because the enumeration requires someone to choose only known values. The `AppEnum` protocol adds metadata that Siri and other system features require to interact with your enumeration or custom type. Add the `AppEnum` protocol to an existing enumeration or type you plan to use in an app intent or app entity. For best results, base your enumeration on a type that’s easily convertible to a string such as the <doc://com.apple.documentation/documentation/swift/string> or <doc://com.apple.documentation/documentation/swift/int> type. The `AppEnum` protocol adds conformance to several other protocols to your type, including the ``TypeDisplayRepresentable`` and ``CaseDisplayRepresentable`` protocols. You’re responsible for implementing these protocols and providing descriptions of your type and each of the cases it contains. The following example shows an enumeration that a workout app uses to specify the available activities. The implementations of the ``TypeDisplayRepresentable/typeDisplayRepresentation`` and ``CaseDisplayRepresentable/caseDisplayRepresentations`` properties provide the protocol-mandated descriptions of the type and each activity. The system uses your descriptions in dialogs and to resolve parameters more quickly. ```swift enum ActivityStyle: String, AppEnum { case biking case equestrian case hiking case jogging case crossCountrySkiing case snowshoeing // Describe the overall type. static var typeDisplayRepresentation: TypeDisplayRepresentation { TypeDisplayRepresentation( name: LocalizedStringResource("Activity style", table: "AppIntents"), numericFormat: LocalizedStringResource("\(placeholder: .int) data", table: "AppIntents")) } // Describe the individual cases. static var caseDisplayRepresentations: [Self: DisplayRepresentation] = [ .biking: DisplayRepresentation(title: "Biking", subtitle: "Mountain bike ride"), .equestrian: DisplayRepresentation(title: "Equestrian", subtitle: "Equestrian sports"), .hiking: DisplayRepresentation(title: "Hiking", subtitle: "A lengthy outdoor walk"), .jogging: DisplayRepresentation(title: "Jogging", subtitle: "A gentle run"), .crossCountrySkiing: DisplayRepresentation(title: "Skiing", subtitle: "Cross-country skiing"), .snowshoeing: DisplayRepresentation(title: "Snowshoeing", subtitle: "Walking in the snow") ] } ``` > Note: Don’t adopt the ``AppEntity`` and `AppEnum` protocols in the same type. An app entity type represents data that can change dynamically, whereas an `AppEnum` represents static data that doesn’t change.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

AppEnum.defaultResolverSpecification

This protocol needs associated types that cannot yet cross the bridge.

All AppIntents types →