• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Updating UI Date formats on user NSUserDefault changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Updating UI Date formats on user NSUserDefault changes


  • Subject: Re: Updating UI Date formats on user NSUserDefault changes
  • From: Danny Frey <email@hidden>
  • Date: Tue, 28 Sep 2004 17:26:43 +0100


On Sep 28, 2004, at 17:04, Dan Bernstein wrote:

On Mac OS X v10.3 (don't know about earlier versions),
@"AppleDatePreferencesChangedNotification" and
@"AppleTimePreferencesChangedNotification" are sent to the default
distributed notification center when these preferences are changed by
System Preferences. This is undocumented, though, so use at your own
risk.

-- Dan

Thanks Dan :-). A colleague came up with a something along those lines - thanks Ian C.
Here's his solution:


[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(observeDate:) name:@"AppleDatePreferencesChangedNotification" object:nil];

// Can't find the symbol for a constant AppleDatePreferencesChangedNotification

- (void)observeDate:n {
NSLog(@"%@ %@ %@", NSStringFromSelector(_cmd), [n description], [[NSUserDefaults standardUserDefaults] stringForKey:NSShortDateFormatString]);
}



// Found by doing

[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(observeOther:) name:nil object:nil];

// ... and tweeking the prefs.




On Tue, 28 Sep 2004 11:26:53 -0400, Sean McBride <email@hidden> wrote:
Danny Frey (email@hidden) on Tue, Sep 28, 2004 09:04 said:

In my earlier posting I included a breakdown of some of my current
attempts at getting this working.

So you did. :) Sorry about that, I guess I only read as far as "My
thanks in anticipation, Danny" and didn't realise you kept going after that :)


Your suggestion was indeed the first
thing I tried, unfortunately although I do pick up window position/size
change notifications in my handler for
NSUserDefaultsDidChangeNotification, (proves it's working) the method
does not seem to get called when the Dates Format is changed in
Preferences. It would be nice to get confirmation on this in case it's
something spooky with my system.

Well, as it happens, after replying to your post, I added this
functionality to the app I'm working on, and can confirm exactly what you
are saying! :(


Since we are both seeing this, perhaps the notification is simply not
posted. ;(

I thought maybe I figured it out when I read this: "An
NSNotificationCenter object can only deliver notifications within a
single task. If you want to post a notification to other tasks or receive
notifications from other tasks, use NSDistributedNotificationCenter"


But I tried with NSDistributedNotificationCenter, and I still don't get
any notifications...


Maybe there is a carbon event we can use... off to look :)

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Updating UI Date formats on user NSUserDefault changes (From: Danny Frey <email@hidden>)
 >Re: Updating UI Date formats on user NSUserDefault changes (From: "Sean McBride" <email@hidden>)
 >Re: Updating UI Date formats on user NSUserDefault changes (From: Dan Bernstein <email@hidden>)

  • Prev by Date: Re: Updating UI Date formats on user NSUserDefault changes
  • Next by Date: Re: Finder Notifications List?
  • Previous by thread: Re: Updating UI Date formats on user NSUserDefault changes
  • Next by thread: Re: Updating UI Date formats on user NSUserDefault changes
  • Index(es):
    • Date
    • Thread