How to get country name and country code in iOS development

  NSLocale *locale = [NSLocale currentLocale];

    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

   

    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode

                                                                             value: countryCode]];

use this string for your use..

there is a drawback in this code ..this will not return string in english it returns that string in device language what user used in device,,, to get string alwys in english

use this code 

 

NSLocale *locale = [NSLocale currentLocale];

NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@“en_US”] autorelease];

NSString *country = [usLocale displayNameForKey: NSLocaleCountryCode value: countryCode];

Comments

comments

One Reply to “How to get country name and country code in iOS development”

Leave a Reply

Your email address will not be published. Required fields are marked *