After upgrading to macOS 13, Xcode started to print to console
Picker: the selection "" is invalid and does not have an associated tag, this will give undefined results.
what is wrong here?
struct Piiker: View {
@State var selectOption: [String] = ["1","2","3"]
@State var fieldValue: String = ""
var body: some View {
Picker("Select number", selection: $fieldValue){
ForEach(selectOption, id: \.self){
Text($0)
}
}
}
}
I solved it finally so.
struct Piiker: View {
@State var selectOption: [String] = ["1","2","3"]
@State var fieldValue: String = ""
var body: some View {
Picker("Select number", selection: $fieldValue){
Text("").tag("") //basically added empty tag and it solve the case
ForEach(selectOption, id: \.self){
Text($0)
}
}
}
}
But it still odd, that Picker need that initial value tag for Dynamic dataset. Previously Picker was able to handle ForEach cases the tags, by itself.