xcode 6.1 iOS 8.1 NSLocale displayNameForKey NSLocaleIdentifier return nil

后端 未结 5 2130
旧时难觅i
旧时难觅i 2021-02-12 20:52
- (NSString *)countryNameByCode:(NSString*)countryCode
{
    NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: countryCode}];
    NSStrin         


        
5条回答
  •  清酒与你
    2021-02-12 21:14

    Please try below code, it should work. I tried it on my device as well as simulator 8.1

    - (NSString *)countryNameByCode:(NSString*)countryCode {
      return [[NSLocale systemLocale] displayNameForKey:NSLocaleCountryCode value:countryCode];
    }
    

提交回复
热议问题