Instance Method

addObserver:selector:name:object:suspensionBehavior:

Adds an entry to the receiver’s dispatch table with a specific observer and suspended-notifications behavior, and optional notification name and sender.

Declaration

- (void)addObserver:(id)observer selector:(SEL)selector name:(NSNotificationName)name object:(NSString *)object suspensionBehavior:(NSNotificationSuspensionBehavior)suspensionBehavior;

Parameters

notificationObserver

Object registering as an observer. Must not be nil.

notificationSelector

Selector that specifies the message the receiver sends notificationObserver to notify it of the notification posting. Must not be 0.

notificationName

The name of the notification for which to register the observer; that is, only notifications with this name are delivered to the observer. When nil, the notification center doesn’t use a notification’s name to decide whether to deliver it to the observer.

notificationSender

The object whose notifications the observer wants to receive; that is, only notifications sent by this sender are delivered to the observer. When nil, the notification center doesn’t use a notification’s sender to decide whether to deliver it to the observer.

suspendedDeliveryBehavior

Notification posting behavior when notification delivery is suspended.

Discussion

The receiver does not retain notificationObserver. Therefore, you should always send removeObserver: or removeObserver:name:object: to the receiver before releasing notificationObserver.

See Also

Managing Observers

- addObserver:selector:name:object:

Adds an entry to the notification center's dispatch table with an observer, a selector, and an optional notification name and sender.

- removeObserver:name:object:

Removes matching entries from the receiver’s dispatch table.