I am trying to save a string selection from a picker into CoreData, but it is stating "Picker: the selection "" is invalid and does not have an associated tag, this will give undefined results." I can see all the options, but it won't let me click any of them and its throwing that error down below in the console.
I have the following:
'feeling' is defined in my CoreData Entity as a String & defined in my SleepModel type as a String
PickerValues.swift
class PickerValues {
enum Feeling: String, CaseIterable, Codable {
case great = "Great"
case ok = "OK"
case bad = "Bad"
}
}
In the AddEntryView.swift:
@State var feelingSelect = String()
Picker ("Feeling", selection: $feelingSelect, content: {
ForEach(PickerValues.Feeling.allCases, id: \.self){ feeling in
Text(feeling.rawValue).tag(feeling)
}
}).foregroundColor(.black)
//inside the function called when clicking the add entry button
var sleepModel = SleepModel(feeling: feelingSelect)