How to add percent sign to NSString

Ilya Suzdalnitski picture Ilya Suzdalnitski · Apr 11, 2009 · Viewed 132.8k times · Source

I want to have a percentage sign in my string after a digit. Something like this: 75%.

How can I have this done? I tried:

[NSString stringWithFormat:@"%d\%", someDigit];

But it didn't work for me.

Answer

mouviciel picture mouviciel · Apr 11, 2009

The code for percent sign in NSString format is %%. This is also true for NSLog() and printf() formats.