how can I use % as a character in my NSString? [duplicate]
Possible Duplicate:
How to add percent sign to NSString
Trying to create some string output using the % symbol with no luck:
[NSString stringWithFormat:@"%@% off entire order.",self.discountPercentage.text]
Example output would hopefully be something like: 25% off entire order.
Instead I get some crazy output: 25377777777776ff entire order.
Is there an escape character I need to use before the %?
Use %%
to represent the % characters. (See String Programming Guide: String Format Specifiers)
The code for percent sign in NSString format is %%.This is also true for NSLog() and printf() formats.
精彩评论