- (NSString *)countryNameByCode:(NSString*)countryCode
{
NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: countryCode}];
NSString *countryName = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:identifier];
return countryName;
}
国家名为零。为什么?
发布于 2018-05-02 16:43:21
请尝试下面的代码,它应该可以工作。我在我的设备和模拟器8.1上试过
- (NSString *)countryNameByCode:(NSString*)countryCode {
return [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:countryCode];
}
https://stackoverflow.com/questions/-100008328
复制相似问题