Can Objective-C switch on NSString?

后端 未结 14 1105
不知归路
不知归路 2020-12-04 05:40

Is there a more intelligent way to rewrite this?

if ([cardName isEqualToString:@\"Six\"]) {
    [self setValue:6];
} else if ([cardName isEqualToString:@\"Se         


        
14条回答
  •  离开以前
    2020-12-04 06:06

    A bit late but for anyone in the future I was able to get this to work for me

    #define CASE(str) if ([__s__ isEqualToString:(str)])
    #define SWITCH(s) for (NSString *__s__ = (s); ; )
    #define DEFAULT
    

提交回复
热议问题