我正在开发适用于 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/