1

I am making an application that uses a progress bar.I would like to display the percentage of completion, but inserting a "%" will interfere with the number that will be displayed.

This is what I have

[percentage setText:[NSString stringWithFormat: @"Progress: %.0f", progressBar.progress*100]];

& I would like to insert the "%" at the end of the string. Thanks for your help.

Bug
  • 2,576
  • 2
  • 21
  • 36
tpatiern
  • 415
  • 4
  • 13
  • possible duplicate of [How to add percent sign to NSString](http://stackoverflow.com/questions/739682/how-to-add-percent-sign-to-nsstring) – Mike Mertsock May 28 '14 at 17:18

2 Answers2

11

Just escape the percent %%:

[percentage setText:
    [NSString stringWithFormat: @"Progress: %.0f%%", progressBar.progress*100]];
meda
  • 45,103
  • 14
  • 92
  • 122
3

%% will give you the percent symbol in your string.

jscs
  • 63,694
  • 13
  • 151
  • 195
jnawaz
  • 134
  • 3