I am using the below code for Code and Country name but it returns null.
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSString *country = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
NSLog(@"Language : %@ Lang2 : %@",[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0],[[NSLocale preferredLanguages] objectAtIndex:0]);
NSLog(@"Locale:%@ Code:%@ Name%@:", locale, countryCode, country);
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
fr,
de,
nl,
ja,
es,
tr,
it,
pl,
pt,
);
Logs : Locale:<__NSCFLocale: 0x7fbef943f810> Code:(null) Name(null)
Language : nl Lang2 : nl
Tested both on device and simulator.i don't know whats going on here.It should work fine.Please let me know if you guys have any idea.i am using xcode 6.4.
Finally found the bugger.
I tested the above code in another test project and was working fine but not in my current project. So i used the developer tool FileMerge and compared the two and found a difference in the below line.(xcshareddata->xcschemes->****.xcscheme).
I don't know how the language = "nl" got there may be due to a bad merge but rolling back and re-merge didn't work either.
Manually removing the line solved my Ghostly Problem :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With