Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLocaleCountryCode returns nil

I have a bugreport that states a crash in the following line, where client is an instance of NSMutableDictionary

[client setObject:[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode] forKey:@"country"];

My guess is, that NSLocaleCountryCode returns nil in this line, which leads to adding a nil object to an NSDictionary which would lead to a crash. The question is, has anybody experienced an issue like this before? Are there any reasons NSLocaleCountryCode could be nil for the currentLocale? The documentation doesn't say anything about returning a nil value and I thought this would always return a valid country.

Best regards, Michael

like image 415
Michael Ochs Avatar asked Mar 04 '13 13:03

Michael Ochs


1 Answers

My case was that for debug purposes I had selected custom language in run scheme in Xcode. I had EN, not system language.

Xcode scheme language

like image 149
olejnjak Avatar answered Sep 30 '22 18:09

olejnjak