Search code examples
iphoneiosiboutletcollection

Using outlet Collection to check if all segmented controls have been selected


I am new to outlet collections but believe that it is what I need for what I am trying to do. Basically I have a lot of segmented controls that I would like to check if they have all been selected before continuing. For a single check I know I can do

    int selectedSegment = segment.selectedSegmentIndex;
    if (selectedSegment == -1 )
{
    //do stuff/alert
}

but how do I do it with a collection of them? I have set my IBOutletCollection to:

IBOutletCollection(UISegmentedControl) NSArray *allSegmentControlOutlet;

Im just not sure how to roll through them checking to make sure each one has something selected


Solution

  • for (UISegmentedControl *control in allSegmentControlOutlet)
    {
        if (control.selectedSegmentIndex == -1 )
        {
            //do stuff/alert
        }
    }