Search code examples
cocoacurrencysymbols

How can i get currency symbols from currency code in iphone?


I have get currency code (Eg: USD, EUR, INR) from webservice response. I need to show the currency symbols for the corresponding currency code. If the currency code is USD, i need to show $, if the currency code is EUR i need to show €. How can i do this? Please suggest any idea or sample code to do this. Please help me. Thanks in advance.


Solution

  • This code works charm in my project. I will share this to you all.

    NSString *currencyCode = @"EUR";
        NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:currencyCode] autorelease];
        NSString *currencySymbol = [NSString stringWithFormat:@"%@",[locale displayNameForKey:NSLocaleCurrencySymbol value:currencyCode]];
        NSLog(@"Currency Symbol : %@", currencySymbol);
    

    Thanks.