-4

Sorry I'm a bit new to objective c and I can't find out how to do something as simple as include a percent sign in a string. How is this accomplished in objective c?

Here's what I tried:

 NSString *string = @"%";
    brightnessLabel.text = [NSString stringWithFormat:[@"Brightness: %.0f" stringByAppendingString:string],slider.value];

but the percent doesn't show up. Thanks for the help.

Zach Saucier
  • 24,871
  • 12
  • 85
  • 147
  • When you enter a new question, SO shows you possibly related questions. Please check these before posting. The first one listed is an exact duplicate of your question. – rmaddy May 11 '13 at 01:40

1 Answers1

6

You need to use "%%". So like this:

NSString *string = @"%%";

If you want a number with a percent after it:

brightnessLabel.text = [NSString stringWithFormat:@"Brightness: %.0f%%", slider.value];
user1118321
  • 25,567
  • 4
  • 55
  • 86