NSDistributedNotificationCenter

NSDistributedNotificationCenter Mac OS X 10.0

This class extends the functionality of its superclass, NSNotificationCenter, by providing a means of sending notifications to objects in other tasks. Every task has a default distributed notification center that objects send notifications to, as well as register themselves as observers. To obtain your application's distributed notification center object, use the factory method defaultCenter.

To register an object as a receiver of a specified notification we use the method addObserver:selector:name:object:. The observer is the object that wishes to be notified of the notification identified by name:. The argument selector: specifies what method should be invoked in response to the notification. The object: parameter allows us to restrict the notifications the observer responds to those posted by the specified object. To remove an observer, invoke the method removeObserver:, which removes the observer for all notifications. To be selective about what notifications from which objects to stop observing, use the method removeObserver:name:object:.

NSNotificationCenter provides three methods for posting notifications: postNotification:, postNotificationName:object:, and postNotification-Name:object:userInfo:. Each of these methods offers different levels of control over how the notification is posted.

For more information about the notifications system, see Chapter 2.

figs/cocn_1335.gif

@interface NSDistributedNotificationCenter : NSNotificationCenter
 // Accessor Methods
   - (void)setSuspended:(BOOL)suspended;
   - (BOOL)suspended;
 // Class Methods
   + (id)defaultCenter;
   + (NSDistributedNotificationCenter *)notificationCenterForType:(NSString *)notificationCenterType;
 // Instance Methods
   - (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)aName object:(NSString *)anObject;
   - (void)addObserver:(id)observer selector:(SEL)selector name:(NSString *)name object:(NSString *)object
        suspensionBehavior:(NSNotificationSuspensionBehavior)suspensionBehavior;
   - (void)postNotificationName:(NSString *)aName object:(NSString *)anObject;
   - (void)postNotificationName:(NSString *)aName object:(NSString *)anObject userInfo:(NSDictionary *)aUserInfo;
   - (void)postNotificationName:(NSString *)name object:(NSString *)object userInfo:(NSDictionary *)userInfo
        deliverImmediately:(BOOL)deliverImmediately;
   - (void)removeObserver:(id)observer name:(NSString *)aName
     object:(NSString *)anObject;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes