如何从iphone的货币代码中获得货币符号? [英] How can i get currency symbols from currency code in iphone?
本文介绍了如何从iphone的货币代码中获得货币符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从网络服务响应中获取货币代码(例如:USD,EUR,INR)。我需要显示相应货币代码的货币符号。如果货币代码是USD,我需要显示$,如果货币代码是EUR我需要显示€。我怎么能这样做?请提出任何想法或示例代码。请帮帮我。提前感谢。
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.
推荐答案
此代码在我的项目中工作。我将分享给大家。
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);
感谢。
这篇关于如何从iphone的货币代码中获得货币符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文