Edit

Share via


NSNotificationCenter.AddObserver Method

Definition

Overloads

AddObserver(NSString, Action<NSNotification>)

Adds an observer for the specified notification

AddObserver(NSString, Action<NSNotification>, NSObject)

Adds an observer for the specified notification

AddObserver(NSObject, Selector, NSString, NSObject)

Low-level add-observer API

AddObserver(String, NSObject, NSOperationQueue, 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

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).

Applies to

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

The name of the notification to observe.

notify
Action<NSNotification>

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

fromObject
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).

Applies to

AddObserver(NSObject, Selector, NSString, NSObject)

Low-level add-observer 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
aSelector
Selector
aName
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

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.

Attributes

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.

Applies to

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

To be added.

This parameter can be null.

obj
NSObject

To be added.

This parameter can be null.

queue
NSOperationQueue

To be added.

This parameter can be null.

Returns

Attributes

Applies to