discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Use of 'count' in KVC for NSArray and NSDictionary


From: Helge Hess
Subject: Re: Use of 'count' in KVC for NSArray and NSDictionary
Date: Mon, 13 Mar 2006 17:56:27 +0100

On 13. Mrz 2006, at 14:54 Uhr, Richard Frith-Macdonald wrote:
I believe the behavior of Key Value Coding in MacOS-X has changed compared to the behavior currently implemented in the GNUstep base library for classes like NSArray and NSDictionary. Is there any reason why we should not change to maintain/regain compatibility? The old behavior was to return the count of objects in the collection, but the new behavior seems to be to return an array containing the results of calling -valueForKey:@"count" on all the objects.

To elaborate this a bit further ...

In current Cocoa (10.4) NSArray and NSDictionary are very specific about special KVC keys in those two classes. The rule is simple: if the key starts with an @ (like @count, @max etc), [super valueForKey:] is used to resolve the key instead of doing the collection specific processing (which is performing valueForKey: on the elements for NSArray and using -objectForKey: for NSDictionary).

I *think* this @ rule was always implemented that way in NeXT/Apple stuff (even in early EOF which introduced KVC). And that the GNUstep special keys are an incompatible, GNUstep specific addition (probably someone added that to have a way to access the count of the array but didn't know about the @ stuff).
But I'm not perfectly sure (only 97%).

Gstep-base currently has hacks for special keys w/o the @ prefix and is therefore incompatible with Cocoa.

Greets,
  Helge

PS: actually the @ rule is documented in the Apple docs of NSDictionary but not in NSArray. But the implementation is the same on 10.4, I checked this.
--
http://docs.opengroupware.org/Members/helge/
OpenGroupware.org




reply via email to

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