如何在IOS上显示正确的瑞典货币?

时间:2014-02-20 23:35:12

标签: ios locale nslocale

我写下面的代码用瑞典货币显示给定价格:

+(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。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我尝试使用

[currencyFormatter setCurrencyCode:@"SEK"];

但是没有给出正确的输出。

然后经历了this link

解决方法可能是附加货币的字符串,但我不太确定这是否符合您的要求。