簡體   English   中英

Xcode錯誤“未使用表達結果”

[英]Xcode Error “Expression Result Unused”

我的代碼中出現黃色錯誤,我不確定為什么會得到它。 這是我的代碼:

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

任何幫助將不勝感激,謝謝!

這是您第一次創建NSString嗎? 您沒有使用任何用於創建一個的NSString方法。

正確的語法是:

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

查看NSString參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM