Search code examples
objective-cstringlabelchipmunk

Label only displays %i instead of number


I have a method which creates one ball each time I tap on the screen. Now, I have a label which shall show the score, for now I want to let it show how many balls there are / how many times the user tapped.

The label is called score and I use the following code in the method that is responsible for the tap-ball-creation.

scoreCount += 1;
_score.text = @"%i", scoreCount;
NSLog(@"ScoreCount = %i", scoreCount);

In the debugger it shows scoreCount increasing as it should, but the label only displays %i even though scoreCount is declared in the .h as int.

I already tried to use %f and %d instead but Xcode always tells me "Expression result unused". But why?

P.S.: I'm using chipmunk stuff...


Solution

  • Try changing the second line to _score.text = [NSString stringWithFormat@"%i", scoreCount];