You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ColorPalette.allStaticMembers.map(\.keyPath) // [\ColorPalette.sunrise, ...] as [KeyPath<ColorPalette.Type, Color>]
35
45
```
@@ -40,6 +50,7 @@ Each synthesized entry is a `StaticMember<Container, Value>`: an `Identifiable`
40
50
41
51
```swift
42
52
ForEach(ColorPalette.allStaticMembers) { $color in
53
+
let color = $color.value
43
54
RoundedRectangle(cornerRadius: 12)
44
55
.fill(color)
45
56
.overlay(Text($color.title))
@@ -56,13 +67,36 @@ ForEach(ColorPalette.allStaticMembers) { $color in
56
67
57
68
Because it is a property wrapper, you can also project (`$member`) when you use it on your own properties, and `Identifiable` conformance makes it slot neatly into `ForEach`.
58
69
70
+
## Enum cases (`@CaseIterable`)
71
+
72
+
```swift
73
+
importCaseIterable
74
+
75
+
@CaseIterable
76
+
enumMenuSection {
77
+
casebreakfast
78
+
caselunch
79
+
casedinner
80
+
}
81
+
82
+
ForEach(MenuSection.allCases) { $section in
83
+
Text($section.title)
84
+
.tag($section.id)
85
+
}
86
+
```
87
+
88
+
`@CaseIterable` produces an explicit `allCases: [CaseOf<Enum>]`. `CaseOf` is also a property wrapper, exposing the case name, a title-cased variant, the enum value, and a stable `id` derived from the name.
89
+
59
90
### Access control
60
91
61
92
Need public-facing lists? Pass the desired access modifier:
0 commit comments