简体   繁体   English

Xcode错误“未使用表达结果”

[英]Xcode Error “Expression Result Unused”

I'm getting an yellow error in my code and I'm not sure really why I'm getting it. 我的代码中出现黄色错误,我不确定为什么会得到它。 Here is my code: 这是我的代码:

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

Any help would be really appreciated, Thanks! 任何帮助将不胜感激,谢谢!

Is this your first time creating an NSString? 这是您第一次创建NSString吗? You're not using any of the NSString methods used to create one. 您没有使用任何用于创建一个的NSString方法。

The right syntax is: 正确的语法是:

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

Look at NSString reference . 查看NSString参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM