How can I write cocoa bindings as code instead of in the Interface Builder?
- by johnjohndoe
In my modell got an NSMutableArray that keeps track of a changing number of elements.
In my view I got a NSTextField that shows the number of elements.
The view gots unarchived from the nib file and alloc/inits the modell. Therefore it knowns about the modell and the contained array.
I established the connection as follows. In the Interface Builder at the textfield I added a Cocoa Binding "path" like this: myModell.myArray.@count. By this I can access the count property (which is a must since the array itself does not change).
The binding is based on key-value compliance which I established at the modell so the array can be accessed. But key-value compliance is not part of the questions.
My question: How can I put the binding into the sourcecode and not writing it into the Interface Builder?