Re: IndexOfObject and bindings
Re: IndexOfObject and bindings
- Subject: Re: IndexOfObject and bindings
- From: Clark Cox <email@hidden>
- Date: Thu, 24 Mar 2005 09:19:56 -0500
On Thu, 24 Mar 2005 11:07:39 +0900, Julien Palmas
<email@hidden> wrote:
> I have sub-classed NSArrayController but as still don't feel really at
> ease with the binding mechanism, I have some troubles implementing the
> solution you suggested in your precedent mail.
>
> The thing is that I don't clearly understand how a NSArrayController
> does its job. For example, imagine that I have an array of "Person".
> Each of them have an attribute called name
>
> - (NSString *)name;
>
> If bind a column of a NSTableView to this attribute, the binding method
> will be :
> bind:@"value" toObject:@"myController"
> withKeyPath:@"arrangedObjects.name" options:nil
>
> KeyvalueCoding takes the keyPath, gets the object of the first value,
> then the second, and so on ....
> So in this case, we will have
> [[myController arrangedObjects] name]
Actaully, it's:
[[myController valueForKey: @"arrangedObjects"] valueForKey: @"name"];
-[NSArray valueForKey:] is implemented in a way that does just what
you describe; it builds an array with the result of calling
valueForKey: on each of its sub-objects.
>
> but how can that be ???
> [myController arrangedObjects] is supposed to be a NSArray, how come it
> would answer to the method "name" ? there must be a moment when the
> NSArrayController take an object of the array one after another and
> passes the method "name" .....
>
> I am pretty confused ....
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
_______________________________________________
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