Contents

AnyAppEnum

A type-erased representation of an app enumeration that provides dynamic enumeration value access.

Declaration

struct AnyAppEnum

Overview

Use AnyAppEnum to work with enumerations when you don’t know the specific enumeration type at compile time. At compile, the AnyAppEnum structure resolves to your app enum type and gives you access to its value as shown in the following example:

let definitions = IntentDefinitions(
    bundleIdentifier: "com.apple.example"
)
let colorEnum = definitions.enums["Color"]
let priorityEnum = definitions.enums["Priority"]

// Creating enumeration cases.
let redCase = colorEnum.makeCase("red")
let highPriority = priorityEnum.makeCase("high")

// Accessing enumeration properties.
let rawValue = redCase.rawValue  // "red"

// Converting raw values in a type-safe way.
let colorName = try redCase.as(String.self)
let priorityLevel = try highPriority.as(String.self)

Topics

Creating an enum

Converting enum values

Default Implementations

See Also

Intermediate types