Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Package | com.apple.cocoa.foundation |
Companion guide |
NSNotificationQueue objects (or simply notification queues) act as buffers for notification centers (instances of NSNotificationCenter). Whereas a notification center distributes notifications when posted, notifications placed into the queue can be delayed until the end of the current pass through the run loop or until the run loop is idle. Duplicate notifications can also be coalesced so that only one notification is sent although multiple notifications are posted. A notification queue maintains notifications (instances of NSNotification) generally in a first in first out (FIFO) order. When a notification rises to the front of the queue, the queue posts it to the notification center, which in turn dispatches the notification to all objects registered as observers.
Every thread has a default notification queue, which is associated with the default notification center for the task. You can create your own notification queues and have multiple queues per center and thread.
Creates an NSNotificationQueue that uses the application’s default notification center to post notifications.
public NSNotificationQueue
()
Creates an NSNotificationQueue that uses the notification center specified in notificationCenter to post notifications.
public NSNotificationQueue
(NSNotificationCenter notificationCenter)
Returns the default NSNotificationQueue object for the current thread.
public static NSNotificationQueue defaultQueue
()
This object always uses the default notification center object for the same task.
Removes all notifications from the receiver that match the attributes of notification as specified by coalesceMask.
public void dequeueMatchingNotifications
(NSNotification notification, int coalesceMask)
The mask is created by combining the constants NotificationNoCoalescing
, NotificationCoalescingOnName
, and NotificationCoalescingOnSender
.
Puts notification in the receiver.
public void enqueueNotification
(NSNotification notification, int postingStyle)
The queue posts notification to the notification center at the time indicated by postingStyle. The notification queue posts in NSRunLoop.DefaultRunLoopMode
, and it coalesces only notifications in the queue that match both the notification’s name and object.
This method invokes enqueueNotificationWithCoalesceMaskForModes
.
Puts notification in the receiver.
public void enqueueNotificationWithCoalesceMaskForModes
(NSNotification notification, int postingStyle, int coalesceMask, NSArray modes)
The queue posts notification to the notification center at the time indicated by postingStyle, but only if the run loop is in a mode identified by one of the string objects in the modes array. The notification queue coalesces related notifications in the queue as specified by coalesceMask (set using the constants NotificationNoCoalescing
, NotificationCoalescingOnName
, and NotificationCoalescingOnSender
). If modes is null
, the notification queue posts in NSRunLoop.DefaultRunLoopMode
.
These constants specify how notifications are coalesced. They’re used in the third argument of enqueueNotificationWithCoalesceMaskForModes
. You can OR them together to specify more than one.
These constants specify when notifications are posted. They’re used in both enqueueNotification
and enqueueNotificationWithCoalesceMaskForModes
:
© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)