% sign in string objective c

本小妞迷上赌 提交于 2019-12-08 20:16:31

问题


i am wondering how i do a % sign within a NSString, i have tried \% and \\%


回答1:


Try %%.

Short question, short answer. :)




回答2:


just put %% to use a % sign within objective c.




回答3:


There's no special escaping required for percent signs. Just write:

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

...unless you mean NSString stringWithFormat. But your question doesn't say so.




回答4:


According to Apple's 'String Format Specifiers' page, simply use %%.

For example:

NSString * aString = @"50%%";

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



来源:https://stackoverflow.com/questions/3904615/sign-in-string-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!