![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/doc/gnustep-base-doc/Base/Reference/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>NSNotificationCenter class reference</title> </head> <body> <font face="serif"> <a href="Base.html">Up</a> <br /> <h1><a name="title$NSNotification">NSNotificationCenter class reference</a></h1> <h3>Authors</h3> <dl> <dt>Andrew Kachites McCallum (<a href="mailto:mccallum@gnu.ai.mit.edu"><code>mccallum@gnu.ai.mit.edu</code></a>)</dt> <dd> </dd> <dt>Richard Frith-Macdonald (<a href="mailto:rfm@gnu.org"><code>rfm@gnu.org</code></a>)</dt> <dd> </dd> <dt>Richard Frith-Macdonald (<a href="mailto:richard@brainstorm.co.uk"><code>richard@brainstorm.co.uk</code></a>)</dt> <dd> </dd> </dl> <p><b>Copyright:</b> (C) 1996,1999 Free Software Foundation, Inc.</p> <div> <hr width="50%" align="left" /> <h3>Contents -</h3> <ol> <li> <a href="#001000000000">Software documentation for the NSNotification class</a> </li> <li> <a href="#002000000000">Software documentation for the NSNotificationCenter class</a> </li> </ol> <hr width="50%" align="left" /> </div> <h1><a name="001000000000"> Software documentation for the NSNotification class </a></h1> <h2><a name="class$NSNotification">NSNotification</a> : <a rel="gsdoc" href="NSObject.html#class$NSObject">NSObject</a></h2> <blockquote class="declared"> <dl> <dt><b>Declared in:</b></dt> <dd>Foundation/NSNotification.h</dd> </dl> </blockquote> <blockquote> <dl> <dt><b>Conforms to:</b></dt> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSCopying)">NSCopying</a></dd> <dd><a rel="gsdoc" href="NSObject.html#protocol$(NSCoding)">NSCoding</a></dd> </dl> </blockquote> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> Represents a notification for posting to an <a rel="gsdoc" href="#class$NSNotificationCenter">NSNotificationCenter</a> . Consists of a name, an object, and an optional dictionary. The notification center will check for observers registered to receive either notifications with the name, the object, or both and pass the notification instance on to them. </p> <p> </p> <p> This class is actually the interface for a class cluster, so instances will be of a (private) subclass. </p> <p> </div> <b>Method summary</b> <ul> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotification+notificationWithName$object$">+notificationWithName:object:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotification+notificationWithName$object$userInfo$">+notificationWithName:object:userInfo:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotification-name">-name</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotification-object">-object</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotification-userInfo">-userInfo</a></li> </ul> <hr width="50%" align="left" /> <div class="method"> <h3><a name="method$NSNotification+notificationWithName$object$">notificationWithName: object: </a></h3> + (<a rel="gsdoc" href="#class$NSNotification">NSNotification</a>*) <b>notificationWithName:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Create a new autoreleased notification by calling <a rel="gsdoc" href="#method$NSNotification+notificationWithName$object$userInfo$">+notificationWithName:object:userInfo:</a> with a <code>nil</code> user info argument. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotification+notificationWithName$object$userInfo$">notificationWithName: object: userInfo: </a></h3> + (<a rel="gsdoc" href="#class$NSNotification">NSNotification</a>*) <b>notificationWithName:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object<b> userInfo:</b> (<a rel="gsdoc" href="NSDictionary.html#class$NSDictionary">NSDictionary</a>*)info;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Create a new autoreleased notification. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotification-name">name </a></h3> - (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*) <b>name</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the notification name. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotification-object">object </a></h3> - (id) <b>object</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the notification object. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotification-userInfo">userInfo </a></h3> - (<a rel="gsdoc" href="NSDictionary.html#class$NSDictionary">NSDictionary</a>*) <b>userInfo</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the notification user information. </div> <hr width="25%" align="left" /> </div> <h1><a name="002000000000"> Software documentation for the NSNotificationCenter class </a></h1> <h2><a name="class$NSNotificationCenter">NSNotificationCenter</a> : <a rel="gsdoc" href="NSObject.html#class$NSObject">NSObject</a></h2> <blockquote class="declared"> <dl> <dt><b>Declared in:</b></dt> <dd>Foundation/NSNotification.h</dd> </dl> </blockquote> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> GNUstep provides a framework for sending messages between objects within a process called <em>notifications</em>. Objects register with an <code>NSNotificationCenter</code> to be informed whenever other objects post <a rel="gsdoc" href="#class$NSNotification">NSNotification</a> 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. Asynchronous processing is possible using an <a rel="gsdoc" href="NSNotificationQueue.html#class$NSNotificationQueue">NSNotificationQueue</a> . </p> <p> </p> <p> Obtain an instance using the <a rel="gsdoc" href="#method$NSNotificationCenter+defaultCenter"> +defaultCenter </a> method. </p> <p> </p> <p> In a multithreaded process, notifications are always sent on the thread that they are posted from. </p> <p> </p> <p> Use the <a rel="gsdoc" href="NSDistributedNotificationCenter.html#class$NSDistributedNotificationCenter">NSDistributedNotificationCenter</a> for interprocess communications on the same machine. </p> <p> </div> <b>Method summary</b> <ul> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter+defaultCenter">+defaultCenter</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-addObserver$selector$name$object$">-addObserver:selector:name:object:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-addObserverForName$object$queue$usingBlock$">-addObserverForName:object:queue:usingBlock:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-postNotification$">-postNotification:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-postNotificationName$object$">-postNotificationName:object:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-postNotificationName$object$userInfo$">-postNotificationName:object:userInfo:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-removeObserver$">-removeObserver:</a></li> <li><a rel="gsdoc" href="NSNotification.html#method$NSNotificationCenter-removeObserver$name$object$">-removeObserver:name:object:</a></li> </ul> <hr width="50%" align="left" /> <div class="method"> <h3><a name="method$NSNotificationCenter+defaultCenter">defaultCenter </a></h3> + (<a rel="gsdoc" href="#class$NSNotificationCenter">NSNotificationCenter</a>*) <b>defaultCenter</b>;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Returns the default notification center being used for this task (process). This is used for all notifications posted by the Base library unless otherwise noted. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-addObserver$selector$name$object$">addObserver: selector: name: object: </a></h3> - (void) <b>addObserver:</b> (id)observer<b> selector:</b> (SEL)selector<b> name:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> </p> <p> Registers <var>observer</var> to receive notifications with the <var>name</var> notificationName and/or containing <var>object</var> (one or both of these two must be non-nil; <code>nil</code> acts like a wildcard). When a notification of <var>name</var> <var>name</var> containing <var>object</var> is posted, <var>observer</var> receives a <var>selector</var> message with this notification as the argument. The notification center waits for the <var>observer</var> to finish processing the message, then informs the next registree matching the notification, and after all of this is done, control returns to the poster of the notification. Therefore the processing in the <var>selector</var> implementation should be <strong>short</strong>. </p> <p> </p> <p> The notification center does not retain <var>observer</var> or <var>object</var>. Therefore, you should always send removeObserver: or removeObserver:name:object: to the notification center before releasing these objects. <br /> As a convenience, when built with garbage collection, you do not need to remove any garbage collected <var>observer</var> as the system will do it implicitly. </p> <p> </p> <p> NB. For MacOS-X compatibility, adding an <var>observer</var> multiple times will register it to receive multiple copies of any matching notification, however removing an <var>observer</var> will remove <em>all</em> of the multiple registrations. </p> <p> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-addObserverForName$object$queue$usingBlock$">addObserverForName: object: queue: usingBlock: </a></h3> - (id) <b>addObserverForName:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object<b> queue:</b> (NSOperationQueue*)queue<b> usingBlock:</b> (GSNotificationBlock)block;<br /> <div class="availability"> <b>Availability:</b> MacOS-X 10.6.0</div> <br /> <div class="desc"> </p> <p> Returns a new observer added to the notification center, in order to observe the given notification <var>name</var> posted by an <var>object</var> or any <var>object</var> (if the <var>object</var> argument is <code>nil</code>). </p> <p> </p> <p> For the <var>name</var> and <var>object</var> arguments, the constraints and behavior described in -addObserver:name:selector:object: remain valid. </p> <p> </p> <p> For each notification received by the center, the observer will execute the notification <var>block</var>. If the <var>queue</var> is not <code>nil</code>, the notification <var>block</var> is wrapped in a NSOperation and scheduled in the <var>queue</var>, otherwise the <var>block</var> is executed immediately in the posting thread. </p> <p> </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-postNotification$">postNotification: </a></h3> - (void) <b>postNotification:</b> (<a rel="gsdoc" href="#class$NSNotification">NSNotification</a>*)notification;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Posts <var>notification</var> to all the observers that match its NAME and OBJECT. <br /> The GNUstep implementation calls <a rel="gsdoc" href="#method$NSNotificationCenter-postNotificationName$object$userInfo$">-postNotificationName:object:userInfo:</a> to perform the actual posting. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-postNotificationName$object$">postNotificationName: object: </a></h3> - (void) <b>postNotificationName:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Creates and posts a notification using the <a rel="gsdoc" href="#method$NSNotificationCenter-postNotificationName$object$userInfo$">-postNotificationName:object:userInfo:</a> passing a <code>nil</code> user info argument. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-postNotificationName$object$userInfo$">postNotificationName: object: userInfo: </a></h3> - (void) <b>postNotificationName:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object<b> userInfo:</b> (<a rel="gsdoc" href="NSDictionary.html#class$NSDictionary">NSDictionary</a>*)info;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> The preferred method for posting a notification. <br /> For performance reasons, we don't wrap an exception handler round every message sent to an observer. This means that, if one observer raises an exception, later observers in the lists will not get the notification. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-removeObserver$">removeObserver: </a></h3> - (void) <b>removeObserver:</b> (id)observer;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Deregisters <var>observer</var> from all notifications. This should be called before the <var>observer</var> is deallocated. </div> <hr width="25%" align="left" /> </div> <div class="method"> <h3><a name="method$NSNotificationCenter-removeObserver$name$object$">removeObserver: name: object: </a></h3> - (void) <b>removeObserver:</b> (id)observer<b> name:</b> (<a rel="gsdoc" href="NSString.html#class$NSString">NSString</a>*)name<b> object:</b> (id)object;<br /> <div class="availability"> <b>Availability:</b> OpenStep</div> <br /> <div class="desc"> Deregisters <var>observer</var> for notifications matching <var>name</var> and/or <var>object</var>. If either or both is <code>nil</code>, they act like wildcards. The <var>observer</var> may still remain registered for other notifications; use <a rel="gsdoc" href="#method$NSNotificationCenter-removeObserver$"> -removeObserver: </a> to remove it from all. If <var>observer</var> is <code>nil</code>, the effect is to remove all registrees for the specified notifications, unless both <var>observer</var> and <var>name</var> are <code>nil</code>, in which case nothing is done. </div> <hr width="25%" align="left" /> </div> <br /> <a href="Base.html">Up</a> </font> </body> </html>