NSString stringWithFormat百分号

时间:2011-11-07 21:54:49

标签: nsstring stringwithformat

我搜索过,找不到这个答案......

如果我有这个,我怎么能让它显示最终的%符号?它只是在我的标签中省略了它。

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

1 个答案:

答案 0 :(得分:28)

我认为我可以贡献一点并分享 this comprehensive list 选项。杰西是 对!

就我而言,以下是诀窍!

[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

快乐的编码!

相关问题