Share via


NSNotificationCenter.AddObserver Method

Definition

Overloads

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)

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

Parameters

observer
NSObject
aSelector
Selector
aName
NSString
anObject
NSObject
Attributes

Applies to

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

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

Parameters

name
String
obj
NSObject

Returns

Attributes

Applies to