NSNotification |
Mac OS X 10.0 |
Notifications provide a mechanism for objects that have no other way
to communicate with each other. The model used is a multicast model,
in which client objects register themselves with a
notification
center to be notified in response to a certain event, which is
encapsulated in an NSNotification object.
NSNotification represents both notifications to
the notification center, and the notifications that are sent out to
the observers of a particular notification.
Clients generally interact with
notifications
as receivers; that is, they don't create
notifications, but extract key bits of information out of received
notifications. To obtain information about a notification we use the
three methods name, userInfo,
and object, which return the notification name,
userInfo dictionary, and the
notification's associated object, respectively.
@interface NSNotification : NSObject <NSCoding, NSCopying>
|
// Convenience Constructors |
+ (id)notificationWithName:(NSString *)aName object:(id)anObject;
|
+ (id)notificationWithName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo;
|
// Instance Methods |
- (NSString *)name;
|
- (id)object;
|
- (NSDictionary *)userInfo;
|
// Methods Implementing NSCoding |
- (void)encodeWithCoder:(NSCoder *)aCoder;
|
- (id)initWithCoder:(NSCoder *)aDecoder;
|
// Methods Implementing NSCopying |
- (id)copyWithZone:(NSZone *)zone;
|
|