I may have gotten a solution to this. Its not entirely what I was looking for but it does work.
Picker("Category", selection: $eCategoryName) {
ForEach(cats, id: \.self) {
Text($0).tag($0)
}
}
//.pickerStyle(.navigationLink)
.onAppear {
if !pickerLoaded {
if let firstCategory = cats.first {
eCategoryName = firstCategory
pickerLoaded.toggle()
}
}
}
The first time the picker is loaded the selected value is set to the first category in the array. Form validation works because now there's a value in the selected variable. Because the first one is selected, the fact that the first item is checked is irrelevant.
Thanks!
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: