Hi, 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.
Thank you in advance.
Hi, 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.
Thank you in advance.
The code for percent sign in NSString
format is %%
. This is also true for NSLog()
and printf()
formats.
The escape code for a percent sign is "%%", so your code would look like this
[NSString stringWithFormat:@"%d%%", someDigit];
Also, all the other format specifiers can be found at http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html