Converting Country codes to country names on Device with non-english language

前端 未结 1 1887
感动是毒
感动是毒 2021-01-24 20:15

This is the code I am using (Taken from - Converting Country Codes to Country Names)

  NSLocale *locale = [NSLocale currentLocale];
  NSString *countryCode = [lo         


        
相关标签:
1条回答
  • 2021-01-24 20:23

    It is Hebrew and means something like argntynhe or argntynhe or so. (Unfortunately I do not speak any Hebrew. Just converted the unicode to something meaningful.)

    Check the language settings of your device or the locale identifier that you used to initialize your locale with.

    Try this.

    NSLocale myLocale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
    NSString *country = [myLocale displayNameForKey: NSLocaleIdentifier value: identifier];
    

    I am just not positive about the constant @"en_US"; I took that out of the top of my head. Just google for an appropriate value.

    Further docs: https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/classes/NSLocale_Class/Reference/Reference.html

    0 讨论(0)
提交回复
热议问题