5

Possible Duplicate:
How to add percent sign to NSString

I am trying to print red (10.0 %) in Objective-C using the statement:

    $ newlabel1.text= [[NSString alloc] initWithFormat:@"red (%.1f %)",rv];

However, I am getting red(10.0) only, and the % symbol was not printing. How can I make the percentage symbol print?

Michael Harper
  • 14,721
  • 2
  • 60
  • 84
naresh
  • 627
  • 1
  • 7
  • 28

1 Answers1

24

You should double the percent sign (%%).

patapizza
  • 2,398
  • 15
  • 14
  • 2
    The logic behind this being that in anything printf-derived, % normally combines with the character after it to form a format placeholder. So they introduced %% to output just a %. – Tommy Jun 02 '11 at 10:20