Is there a standard way to bind, say, a TextField to an associated value of an enum?
So, given this:
enum Choice {
case one(String)
case two(String)
}
Can I use it in some way as a binding in the View:
@State var choice: Choice = .one("")
var body: some View {
TextField("", text: $choice) // <- this clearly wouldn't work
}
Such that if choice was set to choice = .one(""), then TextField would update the associated value of one.
EDIT
To clarify, can just the associated value of each be bound, so if the choice variable is .one, then .one's associated value would change; same with .two, and so forth.