Hi, I'm learning Cocoa bindings and I'm puzzled. Say you bind the values of two UI objects: an NSSlider and a NSTextField instances to a property (a float) of some NSObject's instance. Yo do the binding using the binding inspector. Moving the slider will change the object's property, whose value will be shown in the text field.
Typing a number in the text field will also adjust the slider's value accordingly.
Apple says syncing is done via KVC and KVO, if I understand what they say about the underlying technologies enabling Cocoa bindings. So I suppose that the slider and textfield are registered as observed of the object's float property (all done behind the scene).
But apparently it's not the case since modifying the value of the float property directly (in code) will not update the slider or the text field. If this relied in KVO, any changes in the property should be observed by the slider and the text field.
Similarly, changing the slider value in code (via slider.floatValue = 0.5
does not change the text field or the float property.
It seems to me that KVO isn't actually in use, but that some messages are sent (using KVC) when user actions directly change the values the slider and the text field. For example, moving the slider would send a message to the NSObject instance to update its float property and to the textfield to change its value. So modifying the NSObject property directly would not do anything, because no observer is registered for changes in this property.
Am I correct?
Typing a number in the text field will also adjust the slider's value accordingly.
Apple says syncing is done via KVC and KVO, if I understand what they say about the underlying technologies enabling Cocoa bindings. So I suppose that the slider and textfield are registered as observed of the object's float property (all done behind the scene).
But apparently it's not the case since modifying the value of the float property directly (in code) will not update the slider or the text field. If this relied in KVO, any changes in the property should be observed by the slider and the text field.
Similarly, changing the slider value in code (via slider.floatValue = 0.5
It seems to me that KVO isn't actually in use, but that some messages are sent (using KVC) when user actions directly change the values the slider and the text field. For example, moving the slider would send a message to the NSObject instance to update its float property and to the textfield to change its value. So modifying the NSObject property directly would not do anything, because no observer is registered for changes in this property.
Am I correct?