bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: valueForKey: on an NSArray


From: Manuel Guesdon
Subject: Re: valueForKey: on an NSArray
Date: Fri, 5 Apr 2002 11:13:20 +0200 (CEST)

On Thu, 4 Apr 2002 23:59:53 -0800 "Jonathan B. Leffert" <jonathan@leffert.net> 
wrote:

 >| Given an NSArray *a, the following explodes
 >| 
 >| [a valueForKey: @"foo"];
 >| 
 >| because NSArray doesn't respond to -foo or -_getFoo or -getFoo when
 >| valueForKey: on an array should return the array represented by calling
 >| valueForKey: on all the objects in the array.  That is, valueForKey: on an
 >| array is the array representing the aggregate of values for the given key.

We've discussed bout this. Here is the final position:
<<
Date: Mon, 25 Feb 2002 11:40:47 +0000
From: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Subject: Re: Re[2]: KeyValueCoding (was Recent key-value encoding changes to 
NSObject.)
To: mguesdon@oxymium.net


On Monday, February 25, 2002, at 10:17 AM, Manuel Guesdon wrote:
>
> I would agree but concerning NSArray compute..., I think it's closely 
> related to it's valueForKey:
> http://developer.apple.com/techpubs/webobjects/Reference/Javadoc/com/webobjects/
> foundation/NSArray.html#valueForKey(java.lang.String)
> <<
> public Object valueForKey(String key)
>     Conformance to the NSKeyValueCoding interface. NSArray's 
> implementation is more complex than the default:
>         * If key indicates an operation that doesn't require an 
> argument, valueForKey performs the operation and returns the result. 
> key indicates an operation if its first character is "@". For example, 
> if key is "@count", valueForKey invokes compute on the "count" 
> operator. This has the effect of computing and returning the number of 
> elements in the receiver. Don't use valueForKey for operations that 
> take arguments; instead use valueForKeyPath.
>         * For keys which do not begin with "@", valueForKey creates a 
> new array with the same number of elements as this array. For each 
> element, the corresponding element in the new array is the result of 
> invoking valueForKeyPath with key as the key path on the element. For 
> example, if key is "firstName", this method returns an array containing 
> the firstName values for each of the array's elements. The key argument 
> can be a key path of the form relationship.property. For example, 
> "department.name". valueForKey replaces null values with an instance of 
> NSKeyValueCoding.Null.
>>>
>
> What do you think ?

I think that you are talking about webobjects specific behavior.  You 
can tell this by the fact that this
is only documented in the webobjects documentation, and the fact that it 
doesn't work like this in MacOS-X
  (I checked by running a test program on MacOS-X 10.1.3).

It looks to me like most (if not all) of the methods in your source file 
are webobjects specific ones
which are not present in the apple Foundation.

>>

and


<<
Date: Sun, 24 Feb 2002 16:18:12 +0000
From: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Subject: Re: EOKeyValueCoding

...
I think this means the basic KVC stuff should be in the base library, 
with webobjects extensions in gsweb
and eof extensions in gdl2.
...
>>


In gdl2, the value returned is an array ofvalues resulting of calling 
valueForKey: on each object of the array
except for functions (keys beginning with @) and 'count' key.

Manuel
--
______________________________________________________________________
Manuel Guesdon - ORANGE CONCEPT <mguesdon@orange-concept.com>
14 rue Jean-Baptiste Clement  -  93200 Saint-Denis  -  France
Tel: +33 1 4940 0997  -  Fax: +33 1 4940 0998




reply via email to

[Prev in Thread] Current Thread [Next in Thread]