I am trying to set the value of a @State var in var a of struct A from a var b of struct B, but it doesn't work. I need to use a @State var because I am passing it as a binding. Ex:
struct A : View {
@State var myBindableVar = ""
var body : some View {
TextField(self.$myBindableVar) ...
}
}
struct B : View {
@State var a : A
var body : some View {
Button(action: { self.a.myBindableVar = "???" }) { ... }
}
}
myBindableVar isn't set to "???" when the button is tapped. Why?