iOS Swift - State Management in SwiftUI
Given the code below, what will be printed when the button is tapped?
class Counter: ObservableObject {
@Published var count = 0
}
struct ContentView: View {
@StateObject var counter = Counter()
var body: some View {
VStack {
Text("Count: \(counter.count)")
Button("Increment") {
counter.count += 1
print(counter.count)
}
}
}
}