iOS NSNumberFormatter 货币代码是如何工作的?

标签 ios locale currency nsnumberformatter

我正在开发适用于 iOS 的应用程序,我正在尝试通过 NSNumberFormatter 提供的货币代码来确定用户的本地货币。我的问题是它是如何工作的?是使用手机的设置来确定本地货币还是联系 iOS App Store?

iOS Developer Library 文档只解释了它将返回什么,但没有说明它是如何确定的。

最佳答案

NSNumberFormatter 为您提供基于您的区域设置的货币代码,它也可以通过像这样为数字格式化程序设置区域设置来更改。

numberFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];

最好根本不设置 currencySymbol。然后,当语言环境是中国 (@"zh_CN") 时,您会得到

此外,您还可以像这样在 nsnumber 上获取与货币相关的属性。

numberFormatter.internationalCurrencySymbol   
numberFormatter.currencySymbol                
numberFormatter.currencyCode  

关于iOS NSNumberFormatter 货币代码是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35194389/

相关文章:

c++ - 使用自定义语言环境注入(inject) stringstream 时出现段错误

angular 5 为 i18n 动态更改语言环境

c# - .NET 中的货币格式

odoo - Odoo 8/9 是否具有多币种电子商务功能?

java - Spring MVC : Difference between spring:message and request locale

xcode - 在 Xcode 的 UILabel 中显示货币符号

ios - 在 Xcode 中构建 Twitter 的 Fabric API 时出现问题

ios - 无法弄清楚如何在 Swift 中使用闭包

ios - 快速打开文件

ios - 如何修复 iOS 13 beta 应用程序打开应用程序时崩溃的问题?