0

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?

Burak
  • 5,706
  • 20
  • 70
  • 110
  • Hello Burak, I recommend you to take a look at following sof answer http://stackoverflow.com/questions/5036971/find-locale-currency-for-iphone-programmatically – casillas Mar 23 '15 at 15:56
  • Thank you @casillas. When I was writing that code, this topic helped me a lot. But I have a different problem now. My client doesn't want the prices are displayed in Arabic letters. – Burak Mar 23 '15 at 16:18

0 Answers0