我之前查过几次,我尝试了答案所说的,但是当我运行 Xcode 的分析器时,它说相同的“消息表达式中的参数是一个未初始化的值”。这是 switch 语句:
`
NSString *imageFile;
switch (randomCoinType) {
case 1:
imageFile = @"coin.1.png";
break;
case 2:
imageFile = @"coin.2.png";
break;
case 3:
case 4:
imageFile = @"coin.3.png";
break;
case 5:
case 6:
case 7:
case 8:
imageFile = @"coin.4.png";
break;
case 9:
imageFile = @"coin.5.png";
break;
case 0:
imageFile = @"coin.6.png";
break;
default:
break;
}
//argument in message is uninitialized here!
Coins *c = [Coins spriteWithFile:imageFile];
c.type = type;
c.position = position;
c.velocity = ccp(0,0);
[coins addObject:c];
[self addChild:c z:2];
}
`