In my model I 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.
I established the connection as follows. In the Interface Builder at the textf开发者_如何学Cield 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).
My question: How can I put the binding into the source code and not writing it into Interface Builder?
With the NSKeyValueBindingCreation protocol. You send something like [someObject bind:@"value" toObject:myModel withKeyPath:@"myArray.@count" options:nil]
.
精彩评论