[Top][All Lists]

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

Re: Re[2]: KVC bug

From: Richard Frith-Macdonald
Subject: Re: Re[2]: KVC bug
Date: Wed, 27 Feb 2002 11:53:15 +0000

On Wednesday, February 27, 2002, at 11:19 AM, Manuel Guesdon wrote:
| PS. Also implemented MacOS-X compatible KVC behavior in NSDictionary.m

It makes troubles for me. Please see the code I've sent and WO specifications at
"allValues", "allKeys", and "count" are special cases.

Could you make some tests on MacOSX to see if your code is right or if mine is right (just adding an object for key
count and see what valueForKey:@"count" give you)  ?

My code is:
@implementation NSDictionary (EOKeyValueCoding)

- (id)valueForKey:(NSString *)key
  id value;
  value = [self objectForKey:key];
  if (!value)
      if ([key isEqualToString:@"allValues"])
        value=[self allValues];
      else if ([key isEqualToString:@"allKeys"])
        value=[self allKeys];
      else if ([key isEqualToString:@"count"])
        value=[NSNumber numberWithInt:[self count]];
  return value;

If your code is right, we have a big problem: how could we have same foundation but 2 differents way of processing
depending on what we use (GNUstepWeb/EOF or not)

My code is correct ... but this should not be a problem.
Your category implementation should 'trump' the implementation in NSDictionary itsself.

So, if you build with just GNUstep-base, you get the Apple Foundation behavior, and if you
build with GNUstepWeb/EOF you get the Apple webobjects behavior.

Of course, we should test this - but methods in categories *should* override the methods
in the original class.

reply via email to

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