Question

I see that the NSLocale bindings aren't complete in MonoTouch so I am having a bit difficulties writing them myself.

Does anyone have the code to get the users countrycode in ISO 3166-1 alpha 3 format? Three letters for each country: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

This is being ported from Android where we already have the API call:

Locale.getDefault().getISO3Country();
Était-ce utile?

La solution

Have a look at Iphone, Obtaining a List of countries from MonoTouch - it should cover it (or easily be adapted to do so).

note: this will be part of a future version of MonoTouch (got the code in a backup waiting for my iMac reparation ;-)

EDIT

iOS NSLocale returns the ISO 2 letters country code not the ISO 3 letters you're looking for. The best you can do is build a map from 2->3 letters and use the linked code to get the 2 letters code. There's some code to do the reverse (that you can adapt) or even a map (to reverse) available in: Converting country codes in .NET

Note that depending on your requirements this could be incomplete and not exactly matching what Android provides you.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top