gpt4 book ai didi

iphone - 如何在 NSString 中使用 % 作为字符?

转载 作者:行者123 更新时间:2023-12-03 20:23:22 25 4
gpt4 key购买 nike

Possible Duplicate:
How to add percent sign to NSString

尝试使用 % 符号创建一些字符串输出,但没有成功:

[NSString stringWithFormat:@"%@% off entire order.",self.discountPercentage.text]

示例输出可能类似于:整个订单 25% 的折扣。

相反,我得到了一些疯狂的输出:25377777777776ff 整个订单。

在 % 之前需要使用转义字符吗?

最佳答案

使用%%来表示%字符。 (参见String Programming Guide: String Format Specifiers)

关于iphone - 如何在 NSString 中使用 % 作为字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6168843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com