Post

Replies

Boosts

Views

Activity

How can I remove duplicates from a Picker
Hi, I created a Picker using an Enum Description Value, however, when rendering, if two cases give the same return the picker shows the value twice. Is there any way to clean the duplicate up? I'll leave an example of my enum and my Picker code and a capture of the rendered Picker // My Enum enum Race: String, CaseIterable { case Ainur, Balrog, Dragon, Dragons, Dwarf, Dwarves, Eagle, Eagles       var description: String {           switch self {             case .Ainur:       return "Ainur"             case .Balrog:       return "Balrog"             case .Dwarf, .Dwarves:       return "Dwarf"             case .Eagle, .Eagles:       return "Eagles" }         // My Picker              Picker("Filter by Race", selection: $raceSelection) {                               ForEach (Race.allCases, id: \.self, content: { race in                                   Text(race.description)                   .tag(race.description)               })             } Thanks!
2
0
720
Dec ’21