Arsen
Arsen

Reputation: 10951

NSLocale force a calendar type

[NSLocale currentLocale] may returns <__NSCFLocale: 0x7ff708516540> 'en_US@calendar=japanese'}

Question: can I say NSLocale do not append calendar=japanese to locale.

Upvotes: 0

Views: 577

Answers (1)

Anbu.Karthik
Anbu.Karthik

Reputation: 82759

Objective-C

   NSString *lang = [[NSLocale preferredLanguages] objectAtIndex:0];
   NSLog(@"language is %@", lang);

  NSString   *langua = [[NSLocale currentLocale] objectForKey: NSLocaleLanguageCode];
  NSLog(@" specified language is %@", langua);

  NSString   *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
  NSLog(@"specified countryCode is %@", countryCode);

the output like

enter image description here

Swift

var lang = NSLocale.preferredLanguages()[0]

let langua = NSLocale.currentLocale().objectForKey(NSLocaleLanguageCode) as! String
let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String

Upvotes: 1

Related Questions