Start New Discussion within our Software Development Community

I want to set a text field to look through a switch statement to find the corresponding case. Can I just do that like this?

switch(textField){
    case 'someCase':
        // do something
        break;
    default:
        // do something else
        break;
}

Considering I already created an outlet for it in the @interface file and have connected a button to this as an action (in the @implementation file).

No switch takes an integer you need if then else if construct

if ([textfield.text isequaltostring:@"someCase"]) {
    // do something
} else if ([textfield.text isequaltostring:@"anotherCase"]) {
    // do something else
} else {
    // do yet another thing
}

No switch takes an integer you need if then else if construct

Really? I didn't know that. Well, thank you. I guess I better go make those if statements.

This question has already been answered. Start a new discussion instead.