List of Countries using NSLocaleCountryCode

daihovey picture daihovey · Aug 24, 2011 · Viewed 15.7k times · Source

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?

Answer

Matt S. picture Matt S. · Aug 24, 2011

Apple uses the ISO-3166 standard.