How to display the correct Swedish currency in iOS?

I wrote the code below to display this price with the Swedish currency:

+(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];
}

This shows the price as 75:00 kr, while it should show 75,00 kr. How can i fix this?

+3
source share
1 answer

I tried to use

[currencyFormatter setCurrencyCode:@"SEK"];

but it did not give the correct result.

Then this link went

Working around could add a string of currency, although I'm not too sure if this will fulfill your requirement.

0
source

All Articles