NSNotificationCenter.AddObserver NSNotificationCenter.AddObserver Method

Definition

Overloads

AddObserver(NSString, Action<NSNotification>) AddObserver(NSString, Action<NSNotification>)

Adds an observer for the specified notification

AddObserver(NSString, Action<NSNotification>, NSObject) AddObserver(NSString, Action<NSNotification>, NSObject)

Adds an observer for the specified notification

AddObserver(NSObject, Selector, NSString, NSObject) AddObserver(NSObject, Selector, NSString, NSObject)

Low-level add-bserver API

AddObserver(String, NSObject, NSOperationQueue, Action<NSNotification>) AddObserver(String, NSObject, NSOperationQueue, Action<NSNotification>)

AddObserver(NSString, Action<NSNotification>) AddObserver(NSString, Action<NSNotification>)

Adds an observer for the specified notification

public Foundation.NSObject AddObserver (Foundation.NSString aName, Action<Foundation.NSNotification> notify);
override this.AddObserver : Foundation.NSString * Action<Foundation.NSNotification> -> Foundation.NSObject

Parameters

aName
NSString NSString

The name of the notification to observe.

notify
Action<NSNotification>

The delegate that will be invoked when the notification is posted.

Returns

An observer token that can be used later as the parameter passed to RemoveObserver (NSObject observer).

AddObserver(NSString, Action<NSNotification>, NSObject) AddObserver(NSString, Action<NSNotification>, NSObject)

Adds an observer for the specified notification

public Foundation.NSObject AddObserver (Foundation.NSString aName, Action<Foundation.NSNotification> notify, Foundation.NSObject fromObject);
override this.AddObserver : Foundation.NSString * Action<Foundation.NSNotification> * Foundation.NSObject -> Foundation.NSObject

Parameters

aName
NSString NSString

The name of the notification to observe.

notify
Action<NSNotification>

The delegate that will be invoked when the notification is posted.

fromObject
NSObject NSObject

If not-null, filters the notifications to those sent by this object.

Returns

An observer token that can be used later as the parameter passed to RemoveObserver (NSObject observer).

AddObserver(NSObject, Selector, NSString, NSObject) AddObserver(NSObject, Selector, NSString, NSObject)

Low-level add-bserver API

[Foundation.Export("addObserver:selector:name:object:")]
public virtual void AddObserver (Foundation.NSObject observer, ObjCRuntime.Selector aSelector, Foundation.NSString aName, Foundation.NSObject anObject);
override this.AddObserver : Foundation.NSObject * ObjCRuntime.Selector * Foundation.NSString * Foundation.NSObject -> unit

Parameters

observer
NSObject NSObject
aSelector
Selector Selector
aName
NSString NSString

Optional name that you want to register with and filter delivery by this name. Use null if you do not want filtering to take place.

This parameter can be null.

anObject
NSObject NSObject

The object that we want to receive notifications from, or null for receiving the specified notifications sent by all objects.

This parameter can be null.

Remarks

This is a low-level version of the AddObserver API that allows the consumer to control the observer and the selector to notify upon notifications.

Developers are encouraged to use the high-level AddObserver(NSString, Action<NSNotification>, NSObject) variant.

AddObserver(String, NSObject, NSOperationQueue, Action<NSNotification>) AddObserver(String, NSObject, NSOperationQueue, Action<NSNotification>)

[Foundation.Export("addObserverForName:object:queue:usingBlock:")]
public virtual Foundation.NSObject AddObserver (string name, Foundation.NSObject obj, Foundation.NSOperationQueue queue, Action<Foundation.NSNotification> handler);
override this.AddObserver : string * Foundation.NSObject * Foundation.NSOperationQueue * Action<Foundation.NSNotification> -> Foundation.NSObject

Parameters

name
String String

To be added.

This parameter can be null.

obj
NSObject NSObject

To be added.

This parameter can be null.

queue
NSOperationQueue NSOperationQueue

To be added.

This parameter can be null.

Returns

Applies to