I have a @State variable that I that I want to add a certain constraint to, like this simplified example:
@State private var positiveInt = 0 {
didSet {
if positiveInt < 0 {
positiveInt = 0
}
}
}
However this doesn't look so nice (it seems to be working though) but what I really want to do is to subclass or extend the property wrapper @State somehow so I can add this constraint in it's setter. But I don't know how to do that. Is it even possible?