2

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();
poupou
  • 43,413
  • 6
  • 77
  • 174
Christer Nordvik
  • 2,518
  • 3
  • 35
  • 52

1 Answers1

1

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.

Community
  • 1
  • 1
poupou
  • 43,413
  • 6
  • 77
  • 174
  • I guess my opinion of easy isn't the same as yours :-) I had a look at that question before posting mine and tried to adapt it with little success. Can you push me a little more in the right direction? Guess I should read up on the bindings part of MonoTouch... – Christer Nordvik Nov 06 '11 at 15:22
  • Thanks! I guess I'll just map them manually since I only need 20-30 countries supported. – Christer Nordvik Nov 06 '11 at 20:38