iphone UIPicker question

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-06-13T18:13:33Z Indexed on 2010/06/13 18:22 UTC
Read the original article Hit count: 137

Filed under:
|

I have a picker that prompts the user to choose a gender and an age group (17-21, 22-26, etc.)

These 2 choices determine which view the user will be brought to after pressing the button, but I am having troubles writing the method for that button. The code I have so far is this:

- (IBAction) buttonPressed {
NSInteger genderRow = [genderPicker selectedRowInComponent:0];
NSString *genderSelected = [genderPickerData objectAtIndex:genderRow];

NSInteger ageRow = [agePicker selectedRowInComponent:1];
NSString *ageSelected = [agePickerData objectAtIndex:ageRow];


if (genderSelected == "Male" && ageSelected == "17-21") {

    Calc2ViewController *calc2ViewController = [[Calc2ViewController alloc] initWithNibName:@"Calc2View" bundle:[NSBundle mainBundle]];

    [self.navigationController pushViewController:calc2ViewController animated:YES];
    [calc2ViewController release];
    calc2ViewController = nil;
}

}

When I run the program, and select these 2 groups (Male and 17-21) - nothing happens. What am I missing?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c