0
我有一个函数如何将字符串/数字附加到字符串?
-(void) generateLevelFromPlist:(int)currentLevel{
NSString *mainPath = [[NSBundle mainBundle] bundlePath];
itemPositionPlistLocation = [mainPath stringByAppendingPathComponent:@"levelconfig.plist"];
NSDictionary * itemPositions = [[NSDictionary alloc] initWithContentsOfFile:itemPositionPlistLocation];
NSNumber *xVal = [[[[itemPositions objectForKey:@"level + STRING/NUMBER"]objectForKey:@"hexposition"]objectForKey:@"hexagon1"]objectForKey:@"xVal"];
int generatedXVal = [xVal integerValue];
NSLog(@"%d", generatedXVal);
NSLog(@"%@", itemPositionPlistLocation);
}
,我想将变量currentLevel为字符串“水平”添加为objectForKey:@"level + STRING/NUMBER"
我该怎么办呢?
太棒了!非常感谢你!顺便说一下,我真正想要的是'myString = [NSString stringWithFormat:@“level%d”,currentLevel]'没有加号... :) –