1.11M Members

How do you assign UI Elements to a switch statement?

 
0
 

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).

 
0
 

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
}
 
0
 

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.

Question Answered as of 1 Year Ago by ChrisPadgham
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article