views:

52

answers:

1

Settting up the observer code:

NSNotificationCenter *defaultCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[defaultCenter addObserver:self
selector:@selector(updateLog:)
    name:@"Update Log"
  object:nil];

Sending the notification code:

[[NSNotificationCenter defaultCenter] postNotificationName:@"Update Log" object:self];

With the method defined as:

-(void)updateLog: (NSNotification *) notification {
NSLog(@"Update Log"); }

The text "Update Log" does not appear in the log when the notification is sent. Thanks for any ideas for why this code is not working.

+5  A: 

There is a difference between "the notification center for workspace notifications" Apple:

[[NSWorkspace sharedWorkspace] notificationCenter]

and "the process’s default notification center" Apple:

[NSNotificationCenter defaultCenter]

You need to pick one of those to use.

Georg Fritzsche
Thanks, now it is working.
Nick Jarboe