Platforms to show: All Mac Windows Linux Cross-Platform
NSKeyValueObserverMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Cocoa | MBS MacBase Plugin | 13.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The NSKeyValueObserving (KVO) informal protocol defines a mechanism that allows objects to be notified of changes to the specified properties of other objects.
You can observe any object properties including simple attributes, to-one relationships, and to-many relationships. Observers of to-many relationships are informed of the type of change made — as well as which objects are involved in the change.
NSObject provides an implementation of the NSKeyValueObserving protocol that provides an automatic observing capability for all objects. You can further refine notifications by disabling automatic observer notifications and implementing manual notifications using the methods in this protocol.
This class implements an observer with event for use in Xojo.
- event observedValueForKeyPathChanged(keyPath as string, target as Variant, change as dictionary, context as Variant, ChangeNSDictionaryRef as Integer) as boolean
- property Handle as Integer
- 4 methods
- method addObserver(keyPath as string, options as Integer = 5, context as Variant = nil)
- method Constructor(TargetHandle as Integer)
- method Destructor
- method removeObserver(keyPath as string, context as Variant = nil)
- 5 shared methods
- shared method NSKeyValueChangeIndexesKey as string
- shared method NSKeyValueChangeKindKey as string
- shared method NSKeyValueChangeNewKey as string
- shared method NSKeyValueChangeNotificationIsPriorKey as string
- shared method NSKeyValueChangeOldKey as string
- 8 constants
Change Kind Constants.
Constant | Value | Description |
---|---|---|
kChangeInsertion | 2 |
Indicates that an object has been inserted into the to-many relationship that is being observed. |
kChangeRemoval | 3 |
Indicates that an object has been removed from the to-many relationship that is being observed. |
kChangeReplacement | 4 |
Indicates that an object has been replaced in the to-many relationship that is being observed. |
kChangeSetting | 1 |
Indicates that the value of the observed key path was set to a new value. This change can occur when observing an attribute of an object, as well as properties that specify to-one and to-many relationships. |
Option Constants
Constant | Value | Description |
---|---|---|
kOptionInitial | 4 | If specified, a notification should be sent to the observer immediately, before the observer registration method even returns. more |
kOptionNew | 1 |
Indicates that the change dictionary should provide the new attribute value, if applicable. Available in OS X v10.3 and later. |
kOptionOld | 2 |
Indicates that the change dictionary should contain the old attribute value, if applicable. Available in OS X v10.3 and later. |
kOptionPrior | 8 | Whether separate notifications should be sent to the observer before and after each change, instead of a single notification after the change. more |
This class has no sub classes.
Some examples using this class:
- /AVFoundation/Donut Video Player
- /AVFoundation/Donut Video Player Overlay
- /AVFoundation/Simple Player
- /AVFoundation/Transparent Player
- /MacCocoa/KeyValueObserver
Blog Entries
The items on this page are in the following plugins: MBS MacBase Plugin.
NSKeyedUnarchiverMBS - NSLayoutManagerMBS