如何在字符串中包含百分比?
这里是一个菜鸟问题。
我有一个代码:
int value = [sender value];
[overLabel setText:[NSString stringWithFormat:@"Overhead: %d", (int)value]];
这将标签设置为(例如):
Overhead: 10
我希望能够将其设置为:
Overhead: 10%
如何将 % 实现到字符串中,这样它就不会被用于打印值,而是被打印作为实际的 % 字符。
谢谢你!
Possible Duplicate:
NSString stringWithFormat adding a percent
a noob question here.
I have a code:
int value = [sender value];
[overLabel setText:[NSString stringWithFormat:@"Overhead: %d", (int)value]];
and this sets the label as (for example):
Overhead: 10
I'd like to be able to set it as:
Overhead: 10%
How do I implement the % into the string so it's not being used to print a value, but it's printed as an actual % character.
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需输入两个%,如下所示:
Just put two %, like this:
您可以使用两个
%
转义%
。You escape the
%
using two%
.