MonoTouch.Foundation.NSObject.AddObserver Method
Registers an object for being observed externally using an arbitrary method.


public IDisposable AddObserver (string key, NSKeyValueObservingOptions options, Action<NSObservedChange> observer)


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.
Flags indicating which notifications you are interested in receiving (New, Old, Initial, Prior).
Method that will receive the observed changes.   It will receive a MonoTouch.Foundation.NSObservedChanged parameter with the information that was changed.


An IDisposable object.  Invoke the Dispose method on this object to remove the observer.


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 specied method (a lambda or method that matches the signature).

This version provides the convenience of exposing the changes as part of the strongly typed MonoTouch.Foundation.NSObservedChanged object that is received by the target.

c# Example

void Setup ()
    AddObserver (rateKey, NSKeyValueObservingOptions.Old | NSKeyValueObservingOptions.New, (observed) => {
        Console.WriteLine ("Change: {0}", observed.Change);
        Console.WriteLine ("NewValue: {0}", observed.NewValue);
        Console.WriteLine ("OldValue: {0}", observed.OldValue);
        Console.WriteLine ("Indexes: {0}", observed.Indexes);
        Console.WriteLine ("IsPrior: {0}", observed.IsPrior);


Namespace: MonoTouch.Foundation
Assembly: monotouch (in monotouch.dll)
Assembly Versions: