Tag: PropertyWrapper
struct StateSample: View { private var counter = 0 var body: some View { Button(action: { self.counter += 1 }, label: { Text("counter is \(counter)") }) } }
struct ParentView: View { @State private var counter = 0 var body: some View { ChildView(counter: $counter) .frame(width: .infinity) } } struct ChildView: View { @Binding var counter: Int var body: some View { Button(action: { counter += 1 }, label: { Text("\(counter)") .font(.title) }) .border(Color.red) } }