Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

theprizerevealed

macrumors regular
Original poster
Feb 26, 2016
183
12
I have several pickers in my app and I want to keep track of the selections of each picker before seguing to the next viewcontroller.

Only after each picker has selected a satisfactory value do I want the current viewcontroller to segue to the next in the sequence.

I tried to use an if statement that evaluates if all pickers have selected a satisfactory value before segueing however the Swift Compiler tells me that evaluating the conditional is too complex to complete in a reasonable time.

I tried to use a simple counter but the Picker seems to trigger the counter when an acceptable value is passed or chosen temporarily but then an alternate value is chosen as the final choice. I cannot seem to make the counter in the Picker code recognize that a new alternate choice was selected and then reset the counter appropriately.

Any helpful suggestions? thanks for your time.
[doublepost=1486868922][/doublepost]After tinkering with the pickerviews and removing all performsegue code then i was surprised to find that after all pickers have chosen a value (whether it is an acceptable value or not) then the viewcontroller segues to the next viewcontroller in sequence. Is that supposed to happen? Is that some feature of pickerview?
 
Last edited:
You should keep track of selected values via Bool, not a counter. If an appropriate value has been selected, set it's Bool = true. So create a Bool for each picker and check if all are true, proceed to the next view.

Yes, all pickers have a default value, set to index[0] of it's data source. It's common to have [0] be empty or have information for what the picker means to the user. In the UIPickerController delegate, let [0] == false for your bools and anything over that == true.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.