Discussion in 'Mac Programming' started by larswik, Sep 1, 2011.

  1. larswik macrumors 68000

    Sep 8, 2006
    I watched this video last night since I subscribed to his videos regarding Bindings.

    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?

  2. admanimal macrumors 68040

    Apr 22, 2005
    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.
  3. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
  4. larswik thread starter macrumors 68000

    Sep 8, 2006
    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.

  5. GorillaPaws macrumors 6502a


    Oct 26, 2003
    Richmond, VA
    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.
  6. larswik thread starter macrumors 68000

    Sep 8, 2006
    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.
  7. zeppenwolf macrumors regular


    Nov 17, 2009

Share This Page