Reputation: 2153
I wanted to allow the user to choose a currency from a list of currencies. Do i have to hardcode all the currencies in the code or can i get it from the api, somehow.
Upvotes: 0
Views: 624
Reputation: 53689
CFLocaleCopyCommonISOCurrencyCodes();
CFLocaleCopyISOCurrencyCodes();
[NSLocale commonISOCurrencyCodes];
[NSLocale ISOCurrencyCodes];
Upvotes: 2
Reputation: 21464
Use [NSLocale ISOCurrencyCodes]
. It gives you an array of all the ISO currency codes as strings.
Upvotes: 1
Reputation: 3863
Since the list of world currencies doesn't change that often, you could go get some current definitive list and add them to your bundle as a property list (an array of strings, if that works, or a dictionary). You can load the plist with framework methods such as dictionaryWithContentsOfFile
or arrayWithContentsOfFile
. Storing the list in a resource is preferable to hard-coding them into your app; and since that list doesn't change that often, I don't see any reason to load them from the internet every time.
Upvotes: 0