[Pyobjc-dev] Binding problem with NSObjectController
Brought to you by:
ronaldoussoren
From: Ben G. <bg...@ob...> - 2004-06-02 05:40:10
|
I wanted to try out the new binding stuff with pyobjc using the the 1.1 release and thought I'd write a very simple little app to see how it went. I've used them before on Obj C and they are great. My app is very simple: it has a class Bump which holds a counter. When you push a button, it uses a binding to send a message to the object which increments (bumps) a counter; the current counter is displayed in a text field. It has an instance created in IB and that's hooked up to an object controller with the appropriate class (Bump). When I run the app, the button connection alone appears to work fine. However, there are all sorts of problems with the binding from the text field to the value in Bump through the NSObjectController. It looks like the NSObjectController is checking for the key value coding compliance very early before the python object has been initialised (using awakeFromNib). If I create the instance variable that the binding observes in an "init" method in the class (note: not __init__), then the key value coding non-compliance warning goes away, presumably because that's called early in the object creation process; if I do that then the button action stops working. Sigh. This is beyond what I can fathom but this does work in Objective C and I believe -- and want it to -- work here too. Any advice appreciated. Ben. |