Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

NSKeyValueObserverMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class Cocoa MBS MacBase Plugin 13.1 Yes No No Yes, macOS only No
Function: The Plugin class to use a key value observer.
Notes:
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 Real Studio.

Feedback, Comments & Corrections

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.
The change dictionary in the notification will always contain an NSKeyValueChangeNewKey entry if kOptionNew is also specified but will never contain an NSKeyValueChangeOldKey entry. (In an initial notification the current value of the observed property may be old, but it's new to the observer.) You can use this option instead of explicitly invoking, at the same time, code that is also invoked by the observer's observedValueForKeyPathChanged method. When this option is used with addObserver a notification will be sent for each indexed object to which the observer is being added.
Available in OS X v10.5 and later.
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.
The change dictionary in a notification sent before a change always contains an NSKeyValueChangeNotificationIsPriorKey entry whose value is true, but never contains an NSKeyValueChangeNewKey entry. When this option is specified the change dictionary in a notification sent after a change contains the same entries that it would contain if this option were not specified. You can use this option when the observer's own key-value observing-compliance requires it to invoke one of the -willChange... methods for one of its own properties, and the value of that property depends on the value of the observed object's property. (In that situation it's too late to easily invoke -willChange... properly in response to receiving an observedValueForKeyPathChanged message after the change.)
Available in OS X v10.5 and later.

This class has no sub classes.

Some examples which use this class:


The items on this page are in the following plugins: MBS MacBase Plugin.


NSKeyedUnarchiverMBS   -   NSLayoutManagerMBS




Links
MBS Xojo PDF Plugins