简体   繁体   English

%符号字符串目标c

[英]% sign in string objective c

我想知道我如何在NSString中做一个%符号,我试过\\%\\\\%

Try %% . 试试%%

Short question, short answer. 简短的问题,简短的回答。 :) :)

只需将%%放在目标c中使用%符号。

There's no special escaping required for percent signs. 百分号没有特殊的逃逸要求。 Just write: 写吧:

str = @"Rate of Return (in %)";

...unless you mean NSString stringWithFormat . ...除非你的意思是NSString stringWithFormat But your question doesn't say so. 但你的问题并没有这么说。

According to Apple's 'String Format Specifiers' page, simply use %% . 根据Apple的“字符串格式说明符”页面,只需使用%%

For example: 例如:

NSString * aString = @"50%%";

Reference: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html 参考: http//developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM