Hi all,
I'm having an issue with a picker. I managed to get all data shown in the picker (here: project.petsArray) but I can't select them.
Most topics found only refer to the usual picker with a given (string) array like
var colors = ["Blue", "Green", "Red"]
I think it got to do with my "project.petsArray" not being an array of strings, right?
Projects is my parent Entity with a one-to-many relationship pointing to the Pets Entity. I've created my petsArray as an extension to Projects to use elsewhere in my app:
public var petsArray: [Pets] {
let set = pets as? Set<Pets> ?? []
return set.sorted {
$0.wrappedPetName < $1.wrappedPetName
}
}
Here is my Picker:
Picker("Pet", selection: $stdPet) {
ForEach(project.petsArray, id: \.self) { pet in
Text(pet.wrappedPetName)
}
}
I thought of converting my petsArray to an Array of Strings to see if that helps but I can't wrap my head around how to do that right now. Is there anything else anyone can think of that may work?
Many thanks in Advance!