我写下面的代码用瑞典货币显示给定价格:
+(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。我该如何解决这个问题?
答案 0 :(得分:0)
我尝试使用
[currencyFormatter setCurrencyCode:@"SEK"];
但是没有给出正确的输出。
然后经历了this link
解决方法可能是附加货币的字符串,但我不太确定这是否符合您的要求。