Hi there,

On 22/08/2006, at 2:53 AM, Chuck Hill wrote:

On Aug 21, 2006, at 7:59 AM, John Huss wrote:

It seems that key-value coding allows serveral different ways of using
functions (like @sum, @avg, etc) in key paths that all seem to work.
Like,

@sum.array.key.path
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Is there a proper way to write these?

I am surprised that these all work. The NSArray documentation implies :-) the that intended use is

<keyPath to array>@<operator>.<keyPath to value>

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" );

If I would like to know how much each person owes:
NSArray totals = ( NSArray )group.valueForKeyPath ( "[EMAIL PROTECTED]" );

It's *very* expressive and useful...

with regards,
--

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to