• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: two-way bindings and one-way bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two-way bindings and one-way bindings


  • Subject: Re: two-way bindings and one-way bindings
  • From: George Orthwein <email@hidden>
  • Date: Wed, 5 Jul 2006 23:56:37 -0400

I think of it as NSUserDefaultsController is "bindings aware", NSPopUpButton is "bindings aware", but your MyObject is not.

To make it bindings aware, you need to do the same stuff you'd do to a custom view... such as the joystick control in mmalc's Graphics Bindings example. Basically, it's implementing bind:toObject:withKeyPath:options: so that you can store the bound object and keypath, so that when you modify MyObject, it can send updates to the bound object via KVC.

That was most likely a horrible explanation, look here instead. :)
http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaBindings/Concepts/HowDoBindingsWork.html#//apple_ref/doc/uid/ 20002373-196748


I wondered once in a post why the "KVO part" is handled automatically with bind:toObject:withKeyPath:options: but the "KVC part" is not set up automatically. (Or, as you put it, one-way is given for free but not two-way.) I just chalk it up to something with the underlying technology that I don't understand.
...
On further thought, maybe it's all there in that link. We can see the implementations of bind:toObject:withKeyPath:options: set up the KVO part. So if you don't re-implement it, and you use your ivar name as the binding name, you can get that part "for free". Sending changes to the bound object via KVC just has to be done in a different place.


Starting to make sense, I think... but still need to think on it more.

George
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: two-way bindings and one-way bindings
      • From: George Orthwein <email@hidden>
References: 
 >two-way bindings and one-way bindings (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: NSCell mouse tracking best practices.
  • Next by Date: Re: two-way bindings and one-way bindings
  • Previous by thread: two-way bindings and one-way bindings
  • Next by thread: Re: two-way bindings and one-way bindings
  • Index(es):
    • Date
    • Thread