CPObjectCPNotificationCenter
@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 CPNotification
s 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. |
Method Detail |
---|
+(CPNotifcationCenter)defaultCenter
-(id)init
-(void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject
nil
.anObserver
- the observing objectaSelector
- the message sent to the observer when a notification occurrsaNotificationName
- the name of the notification the observer wants to watchanObject
- the object in the notification the observer wants to watch-(void)postNotification:(CPNotification)aNotification
aNotification
- the notification being postedCPInvalidArgumentException
- if aNotification is nil
-(void)postNotificationName:(CPString)aNotificationName object:(id)anObject
aNotificationName
- the name of the notificationanObject
- the associated object-(void)postNotificationName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo
aNotificationName
- the name of the notification nameanObject
- the associated objectaUserInfo
- the associated dictionary-(void)removeObserver:(id)anObserver
anObserver
- the observer to unregister-(void)removeObserver:(id)anObserver name:(CPString)aNotificationName object:(id)anObject
anObserver
- the observer to removeaNotificationName
- the name of notifications to no longer watchanObject
- notifications containing this object will no longer be watchedCreated on Sat Sep 13 14:15:43 PDT 2008