3

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,

Ashutosh
  • 5,614
  • 13
  • 52
  • 84

1 Answers1

2

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.

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
  • Ok i got it my other question is will this get the country as India if the user is in India no matter what. Because what i am trying to do is to pass the country name in which the user in (he could be traveller too.) – Ashutosh Aug 09 '11 at 20:45
  • That is a separate question - if my answer is correct mark it and create a new one – mmmmmm Aug 09 '11 at 21:28
  • NSLocale stores information about interface language and metrics. It don't have nothing common with reverse geocoding which you should use t find exactly user location. – Serhii Mamontov Aug 09 '11 at 22:58