我使用下面的代码和国家名称,但它返回null.
- NSLocale *locale = [NSLocale currentLocale];
- NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
- NSString *country = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
- NSLog(@"Language : %@ Lang2 : %@",[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0],[[NSLocale preferredLanguages] objectAtIndex:0]);
- NSLog(@"Locale:%@ Code:%@ Name%@:",locale,countryCode,country);
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,Base,fr,de,nl,ja,es,tr,it,pl,pt,);
日志:区域设置:< __ NSCFLocale:0x7fbef943f810>代码:(null)名称(null)
语言:nl Lang2:nl
在设备和模拟器上测试.我不知道这里发生了什么.它应该工作正常.如果你们有任何想法,请告诉我.我正在使用xcode 6.4.