On Jan 3, 2011, at 9:27 AM, Richard Somers wrote:

I would like to establish bindings in Interface Builder between the "objects" created by the custom view and some standard Interface Builder widgets. The problem is 'awakeFromNib' is called AFTER the bindings are established so the bindings never work.


On Jan 3, 2011, at 1:32 PM, Quincey Morris wrote:

If I understand your description correctly, you actually have a bug in your code. At the time 'awakeFromNib' is called, bindings (and therefore KVO observations) already exist on certain properties of your custom view (that is, on the key-paths that represent those properties) -- even though the property values are still nil, though that's not inherently a problem.

My original problem consisted of several problems combined. The most obscure one was related to KVO observations as suggested by Quincey.

I was trying to bind a NSTextField value property to CALayer subclass property in Interface Builder. But changes in the model were not reflected in the user interface. This is because "CALayer’s implementation of automaticallyNotifiesObserversForKey: in 10.5 returns NO for all keys. In 10.6 it works as expected, returning only NO for its own properties."

     http://rhult.github.com/kvo-problems-with-calayer.html

Debugging bindings can be a challenge. In retrospect Apple provided guidance for troubleshooting this specific issue. The 'Troubleshooting Cocoa Bindings' section of 'Cocoa Bindings Programming Topics' states "If changes made to a model value programmatically are not being reflected in the user interface ... You should ensure that: The model class has automatic key-value observing enabled or implements manual key-value observing for the property."

--Richard Somers

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to