0

When moving the following 'ForEach' code into a Picker, the compiler complaints with: "Generic struct 'Picker' requires that 'Currency' conform to 'Hashable'":

        // THIS WORKS PERFECTLY
        ScrollView {
            ForEach(controller.currencyList) { 
                CurrencyView_ForPicker(currency: $0)
            }
        }

         // THIS WILL NOT COMPILE, WHY ????
         Picker("", selection: $controller.currentCurrency) {
             ForEach(controller.currencyList) {
                CurrencyView_ForPicker(currency: $0)
             }
         }
         .pickerStyle(.wheel)

Maybe I have a misunderstanding of "Hashable", but I don't get the reason for this. I thought "Identifiable" is the highest guaranty for uniqueness and it implies 'Hashable'... can somebody please explain, why this happens. What is the logic behind?

LukeSideWalker
  • 7,399
  • 2
  • 37
  • 45

0 Answers0