I'm trying to add a callback to a SwiftUI picker but can't get it to execute. The didSet apparently does not execute when picker value changes. Here's what I've tried so far:
struct ContentView : View {
@State private var picked: Int = 0 {didSet{print("here")}}
var someData = ["a", "b", "c"]
var body: some View {
VStack {
Picker(selection: $picked,
label: Text("")) {
ForEach(0 ..< someData.count) {Text(self.someData[$0]).tag($0)}
}
.pickerStyle(.wheel)
Text("you picked: \(someData[picked])")
}
}
}