Resetting / Reloading UISegmentedControl

Thought of sharing as quick google didn’t land me to the solution. If you want to reset the UISegmentedControl to a state where nothing is selected (this was the requirement for me), then you just need to set its ‘selectedIndex’ to -1. Reminds of C (EOF character = -1 :)). Here is the snippet I wrote on click of reset button:-

NSArray *segmentedControls = [NSArray arrayWithObjects : roadTestConducted, validVehicle];

for(UISegmentedControl *segControl in segmentedControls) {

[segControl setSelectedSegmentedIndex:-1];

Hope one finds this useful