When I try to output the value of an @State property in the Xcode console with po
I get this error:
po myValue
error: expression failed to parse:
error: Couldn't lookup symbols:
MyApp.MainView.myValue.getter : Swift.Double
Tried with p myValue
but it gives same error, the only way to get something is via
CodePudding user response:
The only working solution for now that I know if is with:
po _myValue._value
but I am not sure if this is the correct way of doing it.
CodePudding user response:
@State
is actually a Property Wrapper. What that means is, when you create:
@State var myValue: T
myValue
is actually a computed property, in the form similar to:
var myValue: T {
get { _myValue.wrappedValue }
set { _myValue.wrappedValue = newValue }
}
Where as the actual property is stored as:
var _myValue: State<T>
Which is why po myValue
wasn't working, and you must've used po _myValue
instead.