Ashutosh
Ashutosh

Reputation: 5742

How to test NSLocale return value?

I am using NSLocale to determine my current country and then pass it as an argument to my web service but i can't test other countries such as Africa etc. through this. Is there a way to test this? I am doing this to get the country name:

NSLocale *locale = [NSLocale currentLocale];
    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];

Thanks,

Upvotes: 3

Views: 944

Answers (1)

mmmmmm
mmmmmm

Reputation: 32681

From the NSLocale class reference

[NSLocale availableLocaleIdentifiers] returns an NSArray of strings of locales the device understands. Each of these can be passed to [[NSLocale alloc] initWithLocaleIdentifier:aString] to give you a locale to test with.

Upvotes: 2

Related Questions