I have following code to show prices string:
+(NSString *) getPriceStringWithCurrencySymbolFor:(NSNumber *)price{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if([appDelegate.shop.localeCode isEqualToString:@"ar_AE"])
return [NSString stringWithFormat:@"%d",[price integerValue]];
NSDictionary *components = [NSDictionary dictionaryWithObject:appDelegate.shop.localeCode forKey:NSLocaleCurrencyCode];
NSString *localeIdentifier = [NSLocale localeIdentifierFromComponents:components];
NSLog(@"localeIdentifier: %@", localeIdentifier);
NSLocale *localeForDefaultCurrency = [[NSLocale alloc] initWithLocaleIdentifier:appDelegate.shop.localeCode];
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setLocale:localeForDefaultCurrency];
[currencyFormatter setMaximumFractionDigits:3];
[currencyFormatter setMinimumFractionDigits:0];
[currencyFormatter setAlwaysShowsDecimalSeparator:YES];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
if([appDelegate.shop.localeCode isEqualToString:@"ar_KW"]){
[currencyFormatter setCurrencyDecimalSeparator:@"."];
}
else{
[currencyFormatter setCurrencyDecimalSeparator:@","];
}
NSLog(@"currency symbol: %@", [currencyFormatter currencySymbol]);
return [currencyFormatter stringFromNumber:price];
}
Until now, it worked good. But now, I should display currency for Kuwait Dinari. If I set appDelegate.shop.localeCode for ar_KW (Kuwait), the function gives the price in Arabic. What I need is, displaying the price like "1.750 KWD". How can I do that?