Closed WedgeSparda closed 8 years ago
What about adding a setter to the text
property? We can handle it just like the text contained in the textField, as it would mostly be a shortcut for that (as it already is now): we also already have all the checks in place (see #11 and #12) to handle wrong input data.
The idea would be something like this: [picker setSelectedOptionIndex:3];
Then, the text field text would match that option's string value.
This way, you could change picker's value programmatically too.
Aah ok: you want to set a default selected option index too. I'll do both things this evening.
Yes, the important thing here is to avoid that the default selected text doesn't exists in the data array.
Actually the option was already there, setDefaultValue
was doing exactly that. Anyway, I added a setter for text
and a selectedIndex
property with getter and setter, both of them supporting empty (nil) values, so you can programmatically reset the DownPicker initial state ("clearing" the user selection) by setting text = nil
or selectedIndex = nil
.
I also setup some basic unit testing, now the CI build is passing aswell ^_^
Please let me know if everything is working as intended.
It would be great to add a property to set a default selected option from the dataArray. This way, picker would show a selected option since the beginning.