iPhone OS: making a switch statement that uses string literals as comparators instead of integers
- by nickthedude
So i'd like to do this:
switch (keyPath) {
case @"refreshCount":
//do stuff
case @"timesLaunched":
//do other stuff
}
but apparently you can only use integers as the switch quantity. Is the only way to do this parse the string into an integer identifier and then run the switch statement?
like this:
nsinteger num = nil;
if (keyPath isEqual:@"refreshCount") {
num = 0
}
if (keyPath isEqual:@"timesLaunched") {
num = 1
}
I'm trying to optimize this code to be as quick as possible because its going to get called quite often.
thanks,
Nick