Objective c “Xcode错误”;“未使用的表达式结果”;

Objective c “Xcode错误”;“未使用的表达式结果”;,objective-c,Objective C,我的代码中出现了一个黄色错误,我不知道为什么会出现这个错误。这是我的密码: for (int lives = 5; lives > 0; lives--) { self.HangmanStatus.text = @"Lives Left: %d", lives; //<-- Getting error here } for(int-lifes=5;lifes>0;lifes--) { self.HangmanStatus.text=@“Lives Left:%d”,Liv

我的代码中出现了一个黄色错误,我不知道为什么会出现这个错误。这是我的密码:

for (int lives = 5; lives > 0; lives--)
{
     self.HangmanStatus.text = @"Lives Left: %d", lives; //<-- Getting error here
}
for(int-lifes=5;lifes>0;lifes--)
{

self.HangmanStatus.text=@“Lives Left:%d”,Lives;//这是您第一次创建NSString吗?您没有使用

这是您第一次创建NSString吗?您没有使用

正确的语法是:

self.HangmanStatus.text = [NSString stringWithFormat: @"Lives Left: %d", lives];
请看。

正确的语法是:

self.HangmanStatus.text = [NSString stringWithFormat: @"Lives Left: %d", lives];

请看。

您得到的具体错误是什么?产生令人困惑的错误消息的原因是,在(目标)C中,示例中的逗号(
…%d“,lives
)实际上是逗号运算符的用法,很少使用,而不是逗号作为分隔符的用法。(@JohnSauer已经向您指出了如何修复代码。)您得到的具体错误是什么?错误消息令人困惑的原因是,在(目标)C中,示例中的逗号(
..%d“,lives
)实际上是逗号运算符的用法,很少使用,而不是逗号作为分隔符。(@JohnSauer已经向您指出了如何修复代码。)