Why does this assignment to an @State var in init not work?
class getOldValuesFromDb : ObservableObject {
@State var oldValue: Int = 0
init(){
let val = 999
self.oldValue = val
print("OldValue: \(self.oldValue) and Val: \(val)")
}
}
The value for the val is displayed correctly, but as I assigned it to the oldValue, it still has a value of zero. My print() looks exactly like this:
OldValue: 0 and Val: 999
How it's possible?