Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS8 - Get country names from locale

Tags:

ios8

nslocale

I'm using this code to get the list of countries:

for (NSString *code in [NSLocale ISOCountryCodes])
{
    NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: code}];
    NSString *countryName = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:identifier];
    NSLog(countryName);
}

This works fine in iOS 7.x but fails in iOS8 (beta 2) - with countryName always being nil.

Anyone found an alternative yet?

like image 794
user623396 Avatar asked Dec 30 '25 16:12

user623396


1 Answers

I have also faced with such issue on iOS 8. Try to use systemLocale instead of currentLocale.

like image 160
Pavel Malinnikov Avatar answered Jan 02 '26 03:01

Pavel Malinnikov