Saturday, May 11, 2013

NSLocale autoupdatingCurrentLocale example ios


autoupdatingCurrentLocale

Returns the current logical locale for the current user.
+ (id)autoupdatingCurrentLocale
Return Value
The current logical locale for the current user. The locale is formed from the settings for the current user’s chosen system locale overlaid with any custom settings the user has specified in System Preferences.
The object always reflects the current state of the current user’s locale settings.
Discussion of [NSLocale autoupdatingCurrentLocale]
Settings you get from this locale do change as the user’s settings change (contrast withcurrentLocale).
Note that if you cache values based on the locale or related information, those caches will of course not be automatically updated by the updating of the locale object. You can recompute caches upon receipt of the notification (NSCurrentLocaleDidChangeNotification) that gets sent out for locale changes (see Notification Programming Topics to learn how to register for and receive notifications).
Example of [NSLocale autoupdatingCurrentLocale]
[NSLocale autoupdatingCurrentLocale]
Example of [NSLocale autoupdatingCurrentLocale]
NSLocale *locale = [NSLocale autoupdatingCurrentLocale];
    NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
    NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode value: countryCode];
    NSLog(@"countryName %@", countryName);