|
Within a Form I have a "Your Current Department" Picker for the app user to select their department of employment (Sales, Management, etc.). This Picker's selection pulls from the viewModel. Here is a link to the code on GitHub. The following two errors on the ProfileFormView inhibit compilation:
The "Department" is a variable within the Employee model:
If I add Hashable to this struct, I get the following two errors:
|
|
Try to add those methods in your struct like so
and add protocols to your struct Employee accordingly.
|
|
@ygeras Thank you! Your suggestions removed the errors in my model, but I still have the two errors in the ProfileFormView: "Generic struct 'Picker' requires that 'Department' conform to 'Hashable'" "Referencing initializer 'init(_:selection:content:)' on 'Picker' requires that 'Department' conform to 'Hashable'" |
|
As per Hashable protocol you have to do as follows:
You Department type is enum. But the point is that it is a mixture of associated values and cases without them. On the other hand I found such solution workable
So theoretically this might sovle your problem ->
At least in playgrounds it generates hashValue accordingly. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.