简体   繁体   中英

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? You're not using any of the NSString methods used to create one.

The right syntax is:

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

Look at NSString reference .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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