Name
NSNotification — Mac OS X 10.0
Synopsis
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 ... |
Get Cocoa in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.