Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of Countries using NSLocaleCountryCode

I want to be able to make the app change depending on the users location. Im using the code below:

NSLocale *locale = [NSLocale autoupdatingCurrentLocale];
    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
    NSLog(@"countryName %@", countryName);

which works great, but I want to know how the countryName's will be displayed, so I can set up switch case's, which is hard if you dont know how exactly each country is spelt: USA, United States, United States of America, etc. Is there a list of countryCode from Apple, I cant find one.

Also is there a way to make sure the result is in English?

like image 460
daihovey Avatar asked Aug 24 '11 00:08

daihovey


2 Answers

Apple uses the ISO-3166 standard.

like image 161
Matt S. Avatar answered Oct 07 '22 07:10

Matt S.


"ISO standard ISO-3166" is accurate in most cases, but try selecting "Europe" as a region in iOS settings. You will get a return value of "150". Why "150"? Seems like a region code from here: http://en.wikipedia.org/wiki/UN_M.49. Or from here: http://site.icu-project.org/design/t/territory-region-apis

like image 35
Yevgeni Litvin Avatar answered Oct 07 '22 06:10

Yevgeni Litvin