iPhone 中的整数到字符串格式化程序问题
我知道这是一个很常见的问题,但我真的很困惑。
我只想使用格式化程序将整数值转换为字符串。
例如,
假设整数值像 1252
那么它将转换为 1,252
,如果像 1256256
那么它将转换为 1,256,256
>, 意思是每3位数字后插入逗号..
请帮我解决这样一个基本问题..
提前致谢..
I know this is very common question but I am really stuck in this matter.
I just want to covert Integer value to string using formatter.
Example like,
Suppose the integer value is like 1252
then It will convert into 1,252
and If like 1256256
then It will convert into 1,256,256
, It means to insert comma after every 3 digits..
Please help me to solve such a basic problem..
Thanks in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 NSNumberFormatter 类。将整数转换为 NSNumber 并使用 NSNumberFormatter。
You can use NSNumberFormatter class. Convert integer to NSNumber and use NSNumberFormatter.
查看
NSNumberFormatter
关于setNumberStyle:NSNumberFormatterDecimalStyle
的文档。Check out the
NSNumberFormatter
document aboutsetNumberStyle:NSNumberFormatterDecimalStyle
.