iOS Swift - State Management in SwiftUI
Why does this code cause a compile error?
struct ContentView: View {
@State private var number = 0
func increment() {
number += 1
}
var body: some View {
Button("Add", action: increment)
}
}