Could you please help on how to get country code using
NSLocale
Swift 3
NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String
Locale.current.languageCode!
Similarly as in NSLocale Swift 3, you have to cast the overlay type Locale
back to its
Foundation counterpart NSLocale
in order to retrieve the country code:
if let countryCode = (Locale.current as NSLocale).object(forKey: .countryCode) as? String {
print(countryCode)
}