Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSString stringWithFormat Percent Sign [duplicate]

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];
like image 492
Jesse Avatar asked Nov 07 '11 21:11

Jesse


1 Answers

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!

like image 164
Q8i Avatar answered Sep 28 '22 08:09

Q8i