struct FirstView: View {
@State private var valueToPass : Int = 0
var body: some View {
VStack {
Button(action: {
self.valueToPass += 1
}) {
Text("Increase value \(self.valueToPass)")
}
}
.overlay(
SecondView(valueToGet: $valueToPass)
)
}
}
struct SecondView: View {
@Binding var valueToGet: Int
var body: some View {
VStack {
Text("Show value \(valueToGet)")
.padding(.top, 50)
}
}
}
Even if we change value any view it will update in for both the view