Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to receive input from a segmented control

I am trying to receive the user selection from a segmented control and then save it to NSUserDefaults, i.e., if the first segment is selected then it saves the int "1" to NSUserDefaults, but if the second segment is selected then it saves the int "2" to NSUserDefaults.

like image 342
Josiah Palmer Avatar asked Dec 10 '22 08:12

Josiah Palmer


1 Answers

- (IBAction)totalAction:(id)sender {
    toggleNav = sender; // this is your segmented control 
    if ([toggleNav selectedSegmentIndex] == 0) {
        NSlog(@"i am here");
    } else if ([toggleNav selectedSegmentIndex] == 1) {
        NSlog(@"i am here");
    }
}
like image 109
Anju Avatar answered Dec 26 '22 07:12

Anju