Skip to content

Instantly share code, notes, and snippets.

@minsOne
Created March 31, 2014 13:35
Show Gist options
  • Save minsOne/9892363 to your computer and use it in GitHub Desktop.
Save minsOne/9892363 to your computer and use it in GitHub Desktop.
-(NSString *)getConditionStr:(NSInteger)index
{
static NSDictionary *mapping = nil;
NSString *(^getTitle)(void);
if (!mapping) {
mapping = @{
@1: ^(void){
return [NSString stringWithFormat:@"%@", index % 2 ? @"True1" : @"False1"];
},
@2: ^(void){
return [NSString stringWithFormat:@"%@", index % 2 ? @"True2" : @"False2"];
},
@3: ^(void){
return [NSString stringWithFormat:@"%@", index % 2 ? @"True3" : @"False3"];
}
};
}
getTitle = mapping[@(index)];
return getTitle();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment