Is there a more intelligent way to rewrite this?
if ([cardName isEqualToString:@\"Six\"]) {
[self setValue:6];
} else if ([cardName isEqualToString:@\"Se
I'm kind of late to the party, but to answer the question as stated, there's a more intelligent way:
NSInteger index = [@[@"Six", @"Seven", @"Eight", @"Nine"] indexOfObject:cardName];
if (index != NSNotFound) [self setValue: index + 6];
Note that indexOfObject
will look for the match using isEqual:
, exactly as in the question.