iOS8 - 从区域设置获取国家/地区名称

use*_*396 3 nslocale ios8

我正在使用此代码获取国家/地区列表:

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

这在iOS 7.x中运行良好,但在iOS8(beta 2)中失败 - countryName始终为零.

有人找到了另类吗?

Pav*_*kov 5

我也在iOS 8上遇到过这样的问题.尝试使用systemLocale而不是currentLocale.