I am trying to create a reusable picker and am stumped with getting the foreach loop to function correctly.
I am getting two Errors
Generic struct 'ForEach' requires that 'String' conform to 'RandomAccessCollection'
No exact matches in call to initializer
struct PickerSlector: View { var title: String @Binding var selection: String @Binding var item: String init(_ title: String, selection: Binding<String>, item: Binding<String>){ self.title = title self._selection = selection self._item = item } var body: some View { Picker("", selection: $selection){ ForEach (item, id: \.self) { Text($0) } } .font(Font.custom(Design.PrimaryFont, size: 16)) .foregroundColor(selection == "Select" ? Color(Design.TextDark!) : Color(Design.accent!)) }}