編集

次の方法で共有


NSObservedChange Class

Definition

Changes that ocurred to an object being observed by Key-Value-Observing

public class NSObservedChange
type NSObservedChange = class
Inheritance
NSObservedChange

Remarks

This class exposes the various components that were changes in a Key-Value-Observed property.

These are merely accessors to the underlying NSDictionary that is provided to the ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

Instances of this class are provided to your callback methods that you provide to AddObserver(NSObject, String, NSKeyValueObservingOptions, IntPtr).

You can also create these objects if you have a dictionary that contains the keys from a key-value-observing change.   For example if you override the ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

class MyObserved : NSObject {
    public override ObserveValue (NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
    {
        var change = new NSObservedChange (change);
        // Now you can access the details about the change with the
        // properties in the `change’ variable.

        if (context == MyObservedContext){
            //...
        }
        base.ObserveValue (keyPath, ofObject, change, context);
    }
}

Constructors

NSObservedChange(NSDictionary)

Properties

Change

Records the kind of change that was done to the property.

Indexes

The indexes of the objects that were added, removed or changed.

IsPrior

If this flag is true, this indicates that the observed method is being called before the change takes place.

NewValue

The new value being set on the observed property.

OldValue

The previous value on the observed property.

Applies to