[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: isKindOf: - GSObjCIsKindOf
From: |
Stefan Böhringer |
Subject: |
Re: isKindOf: - GSObjCIsKindOf |
Date: |
27 Aug 2001 13:08:14 +0200 |
On 25 Aug 2001 11:06:49 -0400, Marko Mikulicic wrote:
> Pascal Bourguignon wrote:
> > Marko Mikulicic <mikulici@die.supsi.ch> wrote:
...
> >>I have noticed that those methods in NSObject are defined so:
> >>
> >>
> >>- (BOOL) isKindOf: (Class)aClassObject
> >>{
> >> return [self isKindOfClass: aClassObject];
> >>}
> >>
> >>+ (BOOL) isKindOfClass: (Class)aClass
> >>{
> >> if (aClass == [NSObject class])
> >> return YES;
> >> return NO;
> >>}
> >>- (BOOL) isKindOfClass: (Class)aClass
> >>{
> >> Class class = GSObjCClass(self);
> >>
> >> return GSObjCIsKindOf(class, aClass);
> >>}
> >>
> >>
...
> >
> > [MyFirstClass isKindOfClass:MySecondClass]
>
> That doesn't work!
>
> assert(GSObjCIsKindOf(NSClassFromString(@"ICalendarDate")
> ,
> NSClassFromString(@"NSCalendarDate")));
>
> assert([NSClassFromString(@"ICalendarDate")
> isKindOfClass:
> NSClassFromString(@"NSCalendarDate")]);
>
> fails the second assertions.
The behaviour of the second assertion is correct with respect to the
OPENSTEP spec. +/-isKindOfClass: test wether the classes are identical.
Therefore [subClass isKindOfClass:classOfWhichSubClassIsASubClass]
returns NO. To test for the subClass relationship no OPENSTEP method
exists. You may search the OMNI-Archives (omnigroup.com) to find a
replacement implementation.
However, I wonder why -isKindOfClass: is not implemented as follows:
- (BOOL)isKindOfClass:(Class)aClass
{
Class class = [self class];
return [class isKindOfClass:aClass];
}
Best wishes,
Stefan
- isKindOf: - GSObjCIsKindOf, Marko Mikulicic, 2001/08/24
- Re: isKindOf: - GSObjCIsKindOf, Pascal Bourguignon, 2001/08/24
- Re: isKindOf: - GSObjCIsKindOf, Marko Mikulicic, 2001/08/25
- Re: isKindOf: - GSObjCIsKindOf, Nicola Pero, 2001/08/28
- Re: isKindOf: - GSObjCIsKindOf, Marko Mikulicic, 2001/08/29
- Re: isKindOf: - GSObjCIsKindOf, Stefan Böhringer, 2001/08/30
- Re: isKindOf: - GSObjCIsKindOf, Marko Mikulicic, 2001/08/30
- Message not available
- Re: isKindOf: - GSObjCIsKindOf, Stefan Böhringer, 2001/08/31
- Re: isKindOf: - GSObjCIsKindOf, Nicola Pero, 2001/08/30
Re: isKindOf: - GSObjCIsKindOf, Nicola Pero, 2001/08/28