[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[4]: KeyValueCoding (was Recent key-value encoding changes to NSObject
From: |
Manuel Guesdon |
Subject: |
Re[4]: KeyValueCoding (was Recent key-value encoding changes to NSObject.) |
Date: |
Mon, 25 Feb 2002 12:59:20 +0100 (CET) |
On Mon, 25 Feb 2002 11:40:47 +0000 Richard Frith-Macdonald <address@hidden>
wrote:
>|
>| 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.
Please correct me if I'm wrong, but this mean that we'll have a different
behavious between NSArray in base and NSArray in GNUstepWeb/EOF:
Exemple 1:
NSArray -valueForKey:@"something" won't find a value in base
but in gsweb NSArray -valueForKey:@"something" will return an array
of results of performing valueForKey:@"something" on each object of
the array
Exemple 2:
NSArray -valueForKey:@"lastObject" will return the last object
of the array in base
but in gsweb NSArray -valueForKey:@"lastObject" will return an array
of results of performing valueForKey:@"lastObject" on each object of
the array
Same kind of problem in NSDictionary
Don't you think the performXXforKey mecanism is interesting not only for EOF
but for other uses ?
And what about the idea of "quoted keys" which are interesting for
dictionaries, for example. One usage is that it allow
multi-table criterions without code whith EOF/GNUstepWeb. You'll probably tell
me it's EOF/GNUstepWeb specific but
without this, we can't use valueForKey: to retrieve vaues for keys which have a
"." in them.
Manuel
- Re[4]: KeyValueCoding (was Recent key-value encoding changes to NSObject.),
Manuel Guesdon <=