开发者

how can I use % as a character in my NSString? [duplicate]

This question already has answers here: 开发者_开发知识库 Closed 10 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜