ftp.nice.ch/peanuts/GeneralData/Documents/openstep/OpenStepSpec_rtf.tar.gz#/OpenStepSpec_rtf/FoundationKit/Classes/NSNotification.rtf

This is NSNotification.rtf in view mode; [Download] [Up]

paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc.  All Rights Reserved.

s8 li100 fi0 ri1007 ql f0 b fs36 fs100 
fs36 NSNotification 
pard s21 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 
fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject
fs20 
fs28 s12 f0 b fs24 Conforms To:tab b0 fs28 f1 NSCopying
fi0 NSObject (NSObject)
fs20 
fs28 s13 fi-2771 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSNotification.h
fs20 
fs28 pard s35 li100 fi0 ri1007 ql f0 b fs28 fs20 
fs28 Class Description
fs14 
fs28 pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 
fs28 NSNotification objects provide a flexible way to transmit event information between objects.
fs16 
fs28 Message passing'd0invoking a method'd0is the standard way to convey information between objects. However, this requires the object sending the message to know who the receiver is. At times this explicit binding of two objects is undesirable'd0most notably because it would tie two otherwise independent subsystems. For these instances, a looser broadcast model is introduced: An object posts a notification, which is dispatched to the appropriate receivers through a notification center.
fs16 
fs28 An object may post an NSNotification object (referred to as ai  notification objecti0  or simply, ai  notificationi0 ), which contains information about an object: the notification'27s name, its sender, and an optional dictionary containing other information. Other objects can register themselves as observers to receive notification objects when they are posted. When the event happens, the registered objects receive notifications about it. The object posting the NSNotification object, the object the notification is about, and the observer of the notification may all be different objects. 
fs16 
fs28 An NSNotificationCenter object registers observers for events and notifies the observers if these events occur. An object may ask an NSNotificationCenter object (also known as a i notification centeri0 ) to observe an event regarding another object. If the event occurs, the posting object tells the notification center to notify its observers that this condition has occurred. The notification center then sends a notification to all observing objects. (See the class specification of NSNotificationCenter for more on posting notification objects.)
fs16 
fs28 This notification model frees an object from concern about what objects may want to observe it. An object involved with an event'd0or another object'd0may simply post a notification about that event without knowing what objects'd0if any'd0are observing the event. The notification center takes care of distributing notifications to registered observers. Another benefit of this model is to allow multiple objects to listen for notifications, an effect that might otherwise require explicitly setting up an array.
fs16 
fs28 You instantiate a notification object directly by sending the b notificationWithName:object:b0  or b notificationWithName:object:userInfo:b0  messages to the NSNotification class object. You can also create notifications indirectly through the NSNotificationCenter class using the b postNotificationName:object:b0  and b postNotificationName:object:userInfo:b0  convenience methods. 
fs16 
fs28 You can subclass NSNotification to contain information in addition to the notification name, sender, and dictionary.
fs16 
fs28 NSNotification objects are immutable objects.
fs16 
fs28 The NSNotification class adopts the NSCopying protocol, making it possible to treat notifications as context-independent values that can be copied and reused. You can put notifications in an array and send the b copyb0  message to that array, which recursively copies every item. This essentially allows clients to deal with notifications as first class values that can be copied by collections.
fs16 
fs28 pard s35 li100 fi0 ri1007 ql f0 b fs24 
fs28 Creating Notification Objects
fs14 
fs28 pard s14 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 + (NSNotification *)b notificationWithName:b0 (NSString *)i aName
s16 li7030 fi-6553 fi-5796 i0 b object:b0 (id)i anObjecti0 tab Returns a notification object that associates the name i aNamei0  with the object i anObjecti0 .
s14 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 + (NSNotification *)b notificationWithName:b0 (NSString *)i aName
s16 li7030 fi-6553 fi-5796 i0 b object:b0 (id)i anObjecttab i0 Returns a notification object that associates the name
b userInfo:b0 (NSDictionary *)i userInfoi0 tab tab i aNamei0  with the object i anObjecti0  and the dictionary of arbitrary data i userInfoi0 . i userInfoi0  may be b nilb0 .
pard s35 li100 fi0 ri1007 ql f0 b fs48 
fs28 Querying a Notification Object
fs14 
fs28 pard s14 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (NSString *)b nameb0 tab Returns the name of the notification.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (id)b objectb0 tab Returns the object (such as the sender) that'27s associated with this notification.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (NSDictionary *)b userInfob0 tab Returns a dictionary object associated with this notification. Returns b nilb0  if there is no such object.
fi-6552 fs16 
fs28 fi-6552 
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.