• 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: Behavior bind:toObject:withKeyPath:options:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior bind:toObject:withKeyPath:options:


  • Subject: Re: Behavior bind:toObject:withKeyPath:options:
  • From: mmalcolm crawford <email@hidden>
  • Date: Fri, 23 Apr 2004 09:00:50 -0700

On Apr 23, 2004, at 7:34 AM, email@hidden wrote:

I have started using bind:toObject:withKeyPath:options: in a few places in my code, and I was under the impression that:
[objB bind:@"nameB" toObject:self withKeyPath:@"nameA" options:nil];
would be a two-way link between the objects, i.e. if you modify nameA then the change would propagate to nameB, and viceversa. In reality, the previous call only updates nameB when nameA is changed.
Only by creating the binding in the other direction do I get what I originally expected:
[self bind:@"nameA" toObject:objB withKeyPath:@"nameB" options:nil];
Is this the correct behavior and interpretation of the doc? Any advice against having this use of bindings in one's code?

This will only work automatically if the object you bind (objB in your example) is an instance of a subclass of NSController or NSView...


From: email@hidden
Subject: Re: NSObjectController and NSDefaultsController Binding?
Date: April 21, 2004 9:24:17 PM PDT
To: email@hidden

From Drafts from a few days ago...


On Apr 18, 2004, at 2:37 PM, Allan Odgaard wrote:

So in my example the model object (receiver of bind:...) had to be KVC compliant for the key "title" and the controller had to be KVO compliant for the key "values.title". No other requirements should exist.

Not so.
The observer must also know to send a setValue:forKey: message to the observed controller if and when the value associated with its (the observer's) binding changes. For the model object in your example:

[model bind:@"title"
toObject:[NSUserDefaultsController sharedUserDefaultsController]
withKeyPath:@"values.title"
options:nil];

this is unlikely to be the case.

mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: NSTableView autosave with Cocoa Bindings
  • Next by Date: Re: [OT] Algebra (was: Re: Is Concatenation that complex?)
  • Previous by thread: Behavior bind:toObject:withKeyPath:options:
  • Next by thread: app icons, strings, and drops
  • Index(es):
    • Date
    • Thread