NSString stringWithFormat Percent Sign

Jesse picture Jesse · Nov 7, 2011 · Viewed 8.5k times · Source

I searched and could not find this answer...

If I have this, how can I get it to display the final % symbol? It just omits it in my label.

[NSString stringWithFormat:@"Tries %i%", tries];

Answer

Q8i picture Q8i · Mar 23, 2012

I thought I could contribute a bit and share this comprehensive list of options. Jesse is right!

In my case, the following does the trick!

[NSString stringWithFormat:@"Progress: %.2f%%", progress*100] 
// progress is float ranging 0.0-1.0, 
//and I would like it to print up to 2 decimal point

Happy coding!