• 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
two-way bindings and one-way bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

two-way bindings and one-way bindings


  • Subject: two-way bindings and one-way bindings
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 05 Jul 2006 19:09:25 -0700
  • Thread-topic: two-way bindings and one-way bindings

I have an NSPopUpButton whose values are set up in IB. Its "selectedValue"
is bound to User Defaults values.thing.

This works fine. When the user chooses from the popup, "thing" in User
Defaults changes to match. Similarly, if my code changes "thing" in User
Defaults, the popup changes to match. I describe this as a "two way
binding". Cool.

However, I'd prefer to access this value thru an ivar called "thing" in
MyObject. So in MyObject's awakeFromNib I say:

[self bind:@"thing" toObject:[NSUserDefaultsController
sharedUserDefaultsController] withKeyPath:@"values.thing" options:nil];

This works, but only in one direction. When the user chooses from the popup,
and "thing" in User Defaults changes to match, "thing" in MyObject also
changes. But when my code changes "thing" in MyObject, "thing" in User
Defaults does not change. I describe this as a "one way binding". Alas.

So *why* is this second binding only one-way? Is there something else I need
to do, to make it work in both directions? Thx - m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
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>
  • Prev by Date: RE: NSArrayController, TableView and not showing data
  • Next by Date: Re: NSCell mouse tracking best practices.
  • Previous by thread: Debugging Cocoa at Cocoaheads Lake Forest CA on 7/11
  • Next by thread: Re: two-way bindings and one-way bindings
  • Index(es):
    • Date
    • Thread