Is it possible to use an NSString in a switch statement?
NSString
switch
Or is it better to just use if / else if?
if
else if
I use these macros in my app.
#define CASE(str) if ([__s__ isEqualToString:(str)]) #define SWITCH(s) for (NSString *__s__ = (s); ; ) #define DEFAULT SWITCH (string) { CASE (@"AAA") { break; } CASE (@"BBB") { break; } CASE (@"CCC") { break; } DEFAULT { break; } }
548k questions
547k answers
4 comments
86.3k users