Class CPNotificationCenter

CPObject
    extended byCPNotificationCenter

@implementation CPNotificationCenter : CPObject

Cappuccino provides a framework for sending messages between objects within a process called notifications. Objects register with an CPNotificationCenter to be informed whenever other objects post CPNotifications to it matching certain criteria. The notification center processes notifications synchronously -- that is, control is only returned to the notification poster once every recipient of the notification has received it and processed it.


Method Summary
+(CPNotifcationCenter)defaultCenter
          Returns the application's notification center.
-(id)init
          Initializes the receiver.
-(void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject
          Adds an object as an observer.
-(void)postNotification:(CPNotification)aNotification
          Posts a notification to all observers that match the specified notification's name and object.
-(void)postNotificationName:(CPString)aNotificationName object:(id)anObject
          Posts a new notification with the specified name and object.
-(void)postNotificationName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
          Posts a new notification with the specified name, object, and dictionary.
-(void)removeObserver:(id)anObserver
          Unregisters the specified observer from all notifications.
-(void)removeObserver:(id)anObserver name:(CPString)aNotificationName object:(id)anObject
          Unregisters the specified observer from notifications matching the specified name and/or object.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass


Method Detail

defaultCenter

+(CPNotifcationCenter)defaultCenter
Returns the application's notification center

init

-(id)init
Initializes the receiver
Returns:
the initialized receiver

addObserver

-(void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject
Adds an object as an observer. The observer will receive notifications with the specified name and/or containing the specified object (depending on if they are nil.
Parameters:
anObserver - the observing object
aSelector - the message sent to the observer when a notification occurrs
aNotificationName - the name of the notification the observer wants to watch
anObject - the object in the notification the observer wants to watch

postNotification

-(void)postNotification:(CPNotification)aNotification
Posts a notification to all observers that match the specified notification's name and object.
Parameters:
aNotification - the notification being posted
Throws:
CPInvalidArgumentException - if aNotification is nil

postNotificationName

-(void)postNotificationName:(CPString)aNotificationName object:(id)anObject
Posts a new notification with the specified name and object.
Parameters:
aNotificationName - the name of the notification
anObject - the associated object

postNotificationName

-(void)postNotificationName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
Posts a new notification with the specified name, object, and dictionary.
Parameters:
aNotificationName - the name of the notification name
anObject - the associated object
aUserInfo - the associated dictionary

removeObserver

-(void)removeObserver:(id)anObserver
Unregisters the specified observer from all notifications.
Parameters:
anObserver - the observer to unregister

removeObserver

-(void)removeObserver:(id)anObserver name:(CPString)aNotificationName object:(id)anObject
Unregisters the specified observer from notifications matching the specified name and/or object.
Parameters:
anObserver - the observer to remove
aNotificationName - the name of notifications to no longer watch
anObject - notifications containing this object will no longer be watched

Created on Sat Sep 13 14:15:43 PDT 2008