我编写了以下代码以使用瑞典货币显示给定价格:
+(NSString *) getPriceStringWithCurrencySymbolFor:(NSNumber *)price{
NSDictionary *components = [NSDictionary dictionaryWithObject:@"sv_SE" forKey:NSLocaleCurrencyCode];
NSString *localeIdentifier = [NSLocale localeIdentifierFromComponents:components];
NSLocale *localeForDefaultCurrency = [[NSLocale alloc] initWithLocaleIdentifier:@"sv_SE"];
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setLocale:localeForDefaultCurrency];
[currencyFormatter setMaximumFractionDigits:2];
[currencyFormatter setMinimumFractionDigits:2];
[currencyFormatter setAlwaysShowsDecimalSeparator:YES];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
return [currencyFormatter stringFromNumber:price];
}
它显示价格为 75:00 kr,而它应该显示 75,00 kr。我该如何解决?
最佳答案
我试过用
[currencyFormatter setCurrencyCode:@"SEK"];
但这并没有给出正确的输出。
然后经历了this link
解决方法是附加货币字符串,但我不太确定这是否能满足您的要求。
关于ios - 如何在 IOS 上显示正确的瑞典货币?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21922087/