< Previous PageNext Page > Hide TOC

Receiving Workspace Notifications

Workspace notifications are posted when:

Receiving Workspace Notifications

NSWorkspace notifications are posted to a notification center provided by the NSWorkspace object, instead of going through the application’s default notification center as most notifications do. To receive NSWorkspace notifications, your application must register an observer with the NSWorkspace notification center, returned by the notificationCenter method.

The code fragment in Listing 1 registers a method observerMethod with the NSWorkspace notification center to receive all NSWorkspace notifications:

Listing 1  Registering for workspace notifications

NSNotificationCenter *notCenter;
SEL observerMethodSEL;
 
// Assume -observerMethod:(id)aNotification exists
observerMethodSEL = @selector(observerMethod:);
notCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[notCenter addObserver:self selector:observerMethodSEL
           name:nil object:nil]; // Register for all notifications


< Previous PageNext Page > Hide TOC


© 2002, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-06)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.