gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting NSUserDefaultsDidChangeNotification notifications


From: Stefan Bidi
Subject: Getting NSUserDefaultsDidChangeNotification notifications
Date: Sat, 29 Jan 2011 09:51:10 -0600

I've noticed something weird with getting this notification.  In the NSLocale code I add the NSLocale class as an observer so that autoupdatingCurrentLocale can be updated but don't always get a notification as I'd expect.

The code below outputs:
2011-01-29 09:41:48.404 test[8928] en_US
2011-01-29 09:41:48.406 test[8928] en_US
if there is no "Locale" default in "test" domain.  If I set the default before hand (defaults write test Locale "en_US") it is:
2011-01-29 09:44:44.397 test[8961] en_US
2011-01-29 09:44:44.398 test[8961] pt_BR

Is this correct?  I don't fully grasp the defaults and notification system yet but I expected to get a notification anytime the defaults changed.  If this is, in fact, what is supposed to be happening, how can I get a notification not only when the default change but also whenever it's added?

  {
    NSLocale *autoLocale = [NSLocale autoupdatingCurrentLocale];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSLog (@"%@", autoLocale);
    [defaults setObject: @"pt_BR" forKey: @"Locale"];
    [defaults synchronize];
    NSLog (@"%@", autoLocale);
  }

Stef

reply via email to

[Prev in Thread] Current Thread [Next in Thread]