-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing selected index #13
Comments
McPicker isn't meant to give you an index, its meant to give you the selection result. Thats why the One thing I didn't put in the README which I should perhaps clarify. McPicker takes an array of string arrays,
and during initialization McPicker by default sets
The label would then read If you really do want to know the index I'd suggest doing something like this
Hopefully this helps. If not, feel free to make a PR and we can have a look at what you have in mind. |
@kmcgill88 You saved my day, Thanks! |
The provided solution doesn't work if there are repeats in the data array. For example, if you display a McPicker for selecting user named folders, there is no guarantee that the user has named each folder uniquely. Returning the index of the selected item and then cross referencing that to the data source used when setting up the McPicker is the superior and only safe way to accomplish this. What do you think, @kmcgill88? |
Could be interesting to have the index of the selected item.
I've done it locally directly in the McPicker.swift file here:
I then get the result in the done Handler:
The text was updated successfully, but these errors were encountered: