int number = 3;
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:
@"Apple",[NSNumber numberWithInt:0],
@"Peach",[NSNumber numberWithInt:1],
@"Lemon",[NSNumber numberWithInt:2],
@"Pineapple",[NSNumber numberWithInt:3],
........................,
nil];
NSString *numberToKey = [dict objectForKey:number];
如何在字符串中插入基于int number的dict值?
答案 0 :(得分:3)
将值放入字典的方式相同:
NSString *numberToKey = [dict objectForKey:[NSNumber numberWithInt:number]];