awsome
awsome

Reputation: 2153

Is there a way to have a list of all the currencies from the iphone api?

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

Answers (3)

drawnonward
drawnonward

Reputation: 53689

CFLocaleCopyCommonISOCurrencyCodes();
CFLocaleCopyISOCurrencyCodes();
[NSLocale commonISOCurrencyCodes];
[NSLocale ISOCurrencyCodes];

Upvotes: 2

Nick Forge
Nick Forge

Reputation: 21464

Use [NSLocale ISOCurrencyCodes]. It gives you an array of all the ISO currency codes as strings.

(Link to documentation)

Upvotes: 1

wkw
wkw

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

Related Questions