Re: Proper place for functions in KVC paths?
Re: Proper place for functions in KVC paths?
- Subject: Re: Proper place for functions in KVC paths?
- From: John Larson <email@hidden>
- Date: Tue, 29 Aug 2006 16:20:27 -0500
Hello,
I think the api implies they all work and will have differing
outcomes depending on what you would like to 'sum' or 'count'
etc. e.g., Consider the keypath:
'company.people.accounts.totalLiability'.
If I want to know how much is owed in total:
Number total = ( Number )company.valueForKeyPath
( "@sum.people.accounts.totalLiability" );
I am curious if you have actually used this?
Obviously not enough! Bummer...
I meant company.valueForKeyPath
( "email@hiddenLiability" ) - but that's still wrong.
You can only provide toOne keyPaths after @sum it seems (i.e.,
"email@hiddenLiability" ) which will succeed (having
now tested).
You can think of the keypath as a tokenized string that is evaluated
recursively through the elements toward the end of the string and the
@operators are looking for scalar values to iterate over and
accumulate. So, for company.people.account.totalLiability where
people is the only array, then
email@hiddenLiability would produce the sum as
desired. Suppose, however, that each person had multiple accounts.
The following would also be valid:
email@hiddenemail@hiddenLiability.
The point of this was to not leave the thread with the idea that
there can only be one @operator in a keypath.
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden