How to add percent sign to NSString
The code for percent sign in NSString
format is %%
. This is also true for NSLog()
and printf()
formats.
If that helps in some cases, it is possible to use the unicode character:
NSLog(@"Test percentage \uFF05");
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 Conceptual Strings Articles
The accepted answer doesn't work for UILocalNotification. For some reason, %%%%
(4 percent signs) or the unicode character '\uFF05
' only work for this.
So to recap, when formatting your string you may use %%
. However, if your string is part of a UILocalNotification, use %%%%
or \uFF05
.