PDA

View Full Version : Bindings and key paths




AussieSusan
Sep 11, 2008, 06:13 PM
I have a 'usual' arrangement of a NSTableView that is bound to an NSArrayController which in turn is bound to a KVC compliant controller class which all works nicely.

I have another form (separate nib) that has an NSPopupButton that is bound to its own array controller that contains a key path through its own controller class to the same controller class as above.

(Basically, the first arrangement above is used to maintain a table of valid values which is used as the 'popup' values in the second form).

My problem is that the data is not populated (using the first arrangement above) until after the controls are all displayed on the screen. Therefore the first access of the data by the popup button sees an empty table.

The initial entry of the data (from the 'model' which is an external device in this case) occurs in a KVC-compliant manner and updates the table nicely. However, the popup button does not see the updates and so ends up with an empty popup list. Nor does it see any of the subsequent manual adjustments that are made to the table.

I thought that the KVO part of the binding through a path (with several 'steps') should be able to detect the changes in the same way as the more direct access.

Have I missed some critical item somewhere? Can anyone suggest how to get my popup list to be updated as changes are made in the other view/controller combination?

Thanks

Susan

(OS X 10.5.4, XCode 3.1)



HiRez
Sep 14, 2008, 03:36 PM
Have you tried wrapping the access of the object that's not sending KVO notifications in willChangeValueForKey: and didChangeValueForKey: calls? Without seeing the code it's a little hard to understand exactly...

AussieSusan
Sep 16, 2008, 12:12 AM
HiRez,

Thank you for responding - actually turned out to be a (very stupid) error on my part.

Susan