ios8货币符号前面有国家代码

时间:2014-12-30 08:14:19

标签: objective-c iphone ios8

我正在尝试从区域设置中获取货币符号,但在IOS8中似乎返回的currencySymbol是US $而不是$。有谁知道改变了什么?

谢谢,

NSLocale *lcl = [NSLocale currentLocale];
NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init];
[fmtr setNumberStyle:NSNumberFormatterCurrencyStyle];
[fmtr setLocale:lcl];

NSLog( @"%@", [fmtr internationalCurrencySymbol] );
NSLog( @"%@", [fmtr currencySymbol] );

2014-12-30 00:11:35.617 [1344:424347]美元 2014-12-30 00:11:35.617 [1344:424347] US $

1 个答案:

答案 0 :(得分:0)

如果您想设置$而不是US $,那么您可以参考我的回答Here

NSNumberFormatter * fmt;
NSNumber          * n;

fmt = [ [ NSNumberFormatter alloc ] init ];
n   = [ NSNumber numberWithFloat: 10 ];

[ fmt setFormatterBehavior: NSNumberFormatterBehavior10_4 ];
[ fmt setCurrencySymbol: @"$" ];
[ fmt setNumberStyle: NSNumberFormatterCurrencyStyle ];

// NSLog( @"%@", [ fmt stringFromNumber: n ];

[ fmt release ];

现在使用

Currency.text = [ fmt stringFromNumber: n ];