Foundation.NSObject.AddObserver Method
Registers an object for being observed externally (using string keyPath).   Observed changes are dispatched to the observer’s object NSObject.ObserveValue method.

Syntax

public void AddObserver (NSObject observer, string keyPath, NSKeyValueObservingOptions options, IntPtr context)

Parameters

observer
The object that will receive the notifications.   The object will receive notifications on its NSObject.ObserveValue method.
keyPath
Key-path to use to perform the value lookup. The keypath consists of a series of lowercase ASCII-strings with no spaces in them separated by dot characters.
options
Flags indicating which notifications you are interested in receiving (New, Old, Initial, Prior).
context
Context data passed to the NSObject.ObserveValue method when one of the properties change.

Remarks

When the object is registered for observation, changes to the object specified in the keyPath that match the flags requested in options will be sent to the NSObject.ObserveValue method in the observer object.

To stop receiving notifications, call the NSObject.RemoveObserver method.

c# Example

class MySampleViewController : UIViewController {
    void Setup ()
    {
        Player.AddObserver (this, (NSString)"rate",
            NSKeyValueObservingOptions.Old | NSKeyValueObservingOptions.New,
            IntPtr.Zero);
    }
    public override void ObserveValue (NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr ctx)
    {
        // Handle change.
    }
}

Requirements

Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0