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

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I watched this video last night since I subscribed to his videos regarding Bindings. http://www.youtube.com/watch?v=ESk6YLDtGR8

First I just thought Bindings were just connecting your objects in IB with the IBActions and IBOutlets. Opps..

So if I understand it right Bindings are a way to help you reduce the amount of code you need to write by having objects look at other objects, right?

So if I have a button that rolls a random number I can have the result be displayed in a TextField by binding these objects? Or type something in to one TextField and have it display on another automatically?

Thanks
 
The most common use of bindings is to connect a variable/property from an object to a UI control like a text field. This way, whenever the value of the property is changed in the code, it's new value will automatically be displayed in the text field, and whenever someone edits the value in the text field, the property it is bound to can be automatically updated.
 
I get it. I will read through the Doc's but I was surprised because I thought I was getting a good idea of Object C and then blind sided by Bindings. Thinking I knew what they were and then they are something totally different.

I'll set up a project tonight and play with bindings, after reading the doc's of course.

Thanks!
 
Bindings are a bit of a tricky beast in that they can be very easy to implement, but a pain in the ass to debug. They rely on KVC/KVO, so when things don't behave as expected you're going to be sifting through valueDidChange: forKey: notifications trying to figure out what went wrong where.

I've heard stories about programmers who switched all of their code over to bindings when they first came out (10.3 or 10.4 I think) and have changed everything back to IBOutlets/IBActions over the years because of frustration. The rule of thumb I've been told to go by is to only use bindings for very simple connections, and to avoid using it for more complicated tasks.
 
Good to know. I thought I was missing out on some time saving features. It's probably good to learn it so I know how, just in case Bindings provid a simple solution for something int he future.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.