2014-02-20 43 views
3

我写了下面的代码,以显示给定的价格与瑞典货币:如何在IOS显示正确的瑞典货币?

+(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

什么样的价值,你传递了'appDelegate.shop.localeCode'? – footyapps27

+0

我编辑过。请检查。 – Burak

+0

我可以复制它,我觉得这是基金会的错误。 –

回答

0

我尝试使用

[currencyFormatter setCurrencyCode:@"SEK"]; 

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

然后通过this link

去一个解决可能追加货币的字符串,虽然我不太清楚这是否会满足您的要求。