I am having an issue where my Picker control is binding to the index of the item and not to the value specified in the tag. I am using WatchOS.
Picker("Hour:", selection: $hour) {
ForEach((twentyFourHour ? 0 : 1)..<(twentyFourHour ? 24 : 13)) {
Text(String(format: twentyFourHour ? "%02d" : "%d", $0))
.tag($0)
}
}
when I
print("p: \(period) hr: \(hr) hour: \(hour)")
I get
p: am hr: 0 hour: 0
I have tested by adding an arbitrary value to the tag value and it still seems to be binding to the index. I have tried using the "{ i in " syntax too with the same result.
I am basing this off the Apple documentation: https://developer.apple.com/documentation/swiftui/picker?changes=latest_minor