I have a model struct
struct Temp {
var cityUrlId: String {
get {
print(_cityUrlId)
print("gettting="+StringTool.nullToString(_cityUrlId).trim())
return _cityUrlId
}
set(newValue) {
print("newvalue="+newValue)
_cityUrlId = _cityUrlId
print("_cityUrlId="+_cityUrlId!)
}
}
}
The parent view has a state variable e.g.
@State var temp: Temp
and a child view as a new window with @Binding var temp: Temp
My question is that when the temp in child view sets a value for cityUrlId property, it's ok. but once i set a new value in the parent view, the getter returns nil. why is that?
is the solution for this have to be a class for Temp instead of a struct?