[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why does NSDictionary respond to @selector(name)?
From: |
Nicola Pero |
Subject: |
Re: Why does NSDictionary respond to @selector(name)? |
Date: |
Thu, 9 May 2002 16:15:51 +0100 (BST) |
> Hi,
>
> I am tying to port some code to GNUstep. While doing so I encountred the
> following
>
>
> NSLog(@"valueForKey %@", aKey);
> for (i = 0 ; i < count ; i++)
> {
> id object = [self objectAtIndex:i];
> SEL selector = NSSelectorFromString(aKey);
> id detail = nil;
> NSLog(@"got selector %@", object);
> if ([object respondsToSelector:selector])
> {
> NSLog(@"case 1");
> detail = [object performSelector:selector];
> }
>
>
> Output:
> ======
> May 08 20:25:53 FBTest[6190] valueForKey name
> May 08 20:25:53 FBTest[6190] got selector {name = Person_Extra;
> className = FBObject; }
> May 08 20:25:53 FBTest[6190] case 1
> Bus Error
>
> This code is in a category of NSArray so self is an array and object is
> a dictionary. the dictionary has a key name but it should not have a
> method name in my opinion. Why is [object respondsToSelector:selector]
> returning YES causing a bus error?
I think your problem happens because gnustep's NSObject has a method
- (const char *) name
which is for compatibility with the (very old) NEXTSTEP Object class.
Maybe if nobody uses that method we should drop it.