Is there a better way in Objective-C to do:
if ([elementName isEqual:@"one"]){
// do some stuff
}
else if ([elementName isEqual:@"two"]]{
// do more stuff
}
else if ([elementName isEqual:@"three"]]{
// do more stuff
}
ideally, I would like something like:
//BAD CODE, NOT REAL!!!
switchString(elementName){
@"one":
// do stuff
break;
@"two":
// do more stuff
break;
@"three":
// do more stuff
break;
}
A little bit more concise
another, a little bit more complicated way would be to store the strings and
NSInvocationsin a dictionary and the pull the invocation out using your element name as a key. I would do that if the “do stuff” part is more that a couple of lines in scope