Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Samppaa

macrumors regular
Original poster
Mar 26, 2010
168
23
I was reading my book the cocoa for mac osx third edition aaron hillegasse book and I read about bindings, I somehow find it more confortable to do in the codeway is there really a difference or do I have to force myself to use bindings :S
 
I was reading my book the cocoa for mac osx third edition aaron hillegasse book and I read about bindings, I somehow find it more confortable to do in the codeway is there really a difference or do I have to force myself to use bindings :S

Take a checkbox. With bindings you bind it to some BOOL property. Without bindings, you make it an IBOutlet, you have to initialise its state when the nib file is loaded, change it when the property changes, and add an IBAction that switches its state around. A lot more work.

You can do it either way, but bindings make it easier.
 
I worked with bindings on tavleviews and that stuff, felt that it's more easy to do it in codeway.
 
The jury's still out on best practices for using bindings. They can be a real pain to debug, which is why many people like to use them for simple things such as gnasher729's suggestion. When working with NSTableViews and other more complex views, many people prefer to use old-school delegation.

And of course you can always bind things programatically using bind: toObject: withKeyPath: options:.
 
GorillaPaws are you sure about that?

Considering the ease of use with bindings, I find it hard to believe that anyone would rather roll their own code than using the NSArrayController and other classes.

On the other hand, just using NSArrayController and bindings without understanding how it works, is naive and I wouldn't encourage that.
 
GorillaPaws are you sure about that?

Considering the ease of use with bindings, I find it hard to believe that anyone would rather roll their own code than using the NSArrayController and other classes.

On the other hand, just using NSArrayController and bindings without understanding how it works, is naive and I wouldn't encourage that.

Several well-respected Cocoa programmers have expressed this view. I know some have even gone through the trouble of ripping out most of the bindings.
 
Fair enough.

Don't agree with it myself though.

Bindings are just a tool. They can save a lot of code and are really terrific (especially for simple tasks). But they do add to the "behind-the-scenes" complexity, and can make debugging more complicated interactions harder. There's a tradeoff there that some people are cool with while others aren't.

As an example, I'm building an iTunes-like app that has and source list NSOutlineView which uses delegation, and I plan to use bindings for the tableViews bound to an NSArrayController managing Core Data objects.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.