views:

49

answers:

4

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

+2  A: 

Try %%.

Short answer, short question. :)

Amigable Clark Kant
+1  A: 

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

Gyani
+3  A: 

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.

Codo
A: 

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

izakage