开发者

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

开发者 https://www.devze.com 2023-03-09 06:12 出处:网络
This question already has answers here: 开发者_开发知识库 Closed 10 years ago. Possible 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

精彩评论

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