Re: KVO and relationships
Re: KVO and relationships
- Subject: Re: KVO and relationships
- From: "David Aames" <email@hidden>
- Date: Tue, 21 Nov 2006 12:41:09 +0000
Okay... let's suppose I have a model object which has a property "property"
and I have an NSObjectController whose content is this model object. I also
have a few textfields which are bound programmatically to the controller
object with keypath "selection.name". So I'm trying to get a deeper
understanding of how KVO plays along with bindings... so when I issue:
[textfield bind:@"value" toObject:controller withKeypath:@"selection.name"
options:nil];
would the controller start observing the property "name" and when it
receives a KVO msg emit another KVO message to the textfield mapping "name"
to "selection.name" (I presume all of this is handled by the KVO
implementation automatically)? Or the other possibility is that the
controller will return an object using KVC [controller
valueForKey:@"selection"] and the textfield will actually start observing
the "name" property of the "selection" object (the object returned by
[controller valueForKey:@"selection"])?
Kind regards,
David
On 11/21/06, Scott Stevenson <email@hidden> wrote:
On Nov 20, 2006, at 6:15 AM, David Aames wrote:
> I've been looking more and more into bindings and I've been
> thinking about
> the case when the view observes the model via a controller - e.g. it
> observes the keypath @"content.property". Now when the controller
> handles
> this call does it automatically observe @"property" and handle the
> details
> and emit a KVO message mapping the change in @"property" to @"
> content.property" OR does this call retrieve [controller content]
> and call
> observe:... on the returned value? I think it is the former... but
> what
> would the experts say?
It might all be simpler than you think. Are you just curious how
bindings works or is there something you're trying to accomplish?
It's unusual to use "content.property" as a model keypath. You'd
usually just bind to "property" instead so that the controller can do
its job. It might make sense in your case, but there's no way to know
that without seeing some code from your project.
It might also be that I'm misunderstanding your question because
you're using terms which can have different meanings. For example,
it's not clear to me what what you mean by "call" in the first case:
"Now when the controller handles this call"
Do you mean an explicit call to -bind, or an explicit call to -
observeKeyPath, or an explicit call to -addObserver, or something
else? When you bind a view to a controller, you typically bind to the
controller itself, not the underlying object.
Also, I'd like to take this opportunity to make three requests for
people posting questions. Whenever possible, please:
1. Include sample code
2. Include what your high-level goal is
3. Include urls to screenshots if appropriate
(Could someone add these to the list faq? Pretty please?)
I find the most time-consuming part of answering questions is trying
to figure out what people are asking. The easier it is for others to
understand your question, more likely (and more quickly) it will be
answered.
Posts that roll on for a dozen sentences without any paragraph breaks
are not fun to read.
- Scott
_______________________________________________
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
_______________________________________________
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