I've just started learning SwiftUI, so I'm very new to framework and know very little about the Swift language in general. I'm trying to figure out how to define a custom type.
I've got a @State variable that can be one of three strings ("OFF", "ON", "ONCE").
This is what I have so far:
@State private var mode: String = "OFF"
The problem is, I would like to enforce this variable to conform to a "stricter" type instead of simply setting it to String.
Something akin to this maybe... (I realise this isn't valid, but I'm coming from a TypeScript world so please forgive me)
type Mode = "OFF" | "ON" | "ONCE"
@State private var mode: Mode = "OFF"
Any help would be appreciated. Thanks in advance!