discuss-gnustep
[Top][All Lists]
Advanced

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

Re: little question about class versioning


From: Sebastian Reitenbach
Subject: Re: little question about class versioning
Date: Fri, 14 Sep 2012 18:44:40 +0200
User-agent: SOGoMail 1.3.18

Hi Wolfgang,
 
On Thursday, September 13, 2012 13:28 CEST, Wolfgang Lux 
<wolfgang.lux@gmail.com> wrote: 
 
> Hi Sebastian,
> 
> > which gives me the following output:
> > 
> > 2012-09-13 11:47:30.072 TestTool[27335] SuperClass class_getVersion([super 
> > class]): 8
> > 2012-09-13 11:47:30.081 TestTool[27335] SuperClass 
> > class_getVersion([MyClass class]): 1
> > 2012-09-13 11:47:30.081 TestTool[27335] SuperClass [[super class] version]: 
> > 8
> > 2012-09-13 11:47:30.081 TestTool[27335] SubClass class_getVersion([self 
> > class]): 8
> > 2012-09-13 11:47:30.081 TestTool[27335] SubClass 
> > class_getVersion([MySubClass class]): 8
> > 2012-09-13 11:47:30.081 TestTool[27335] SubClass [[self class] version]: 8
> > 
> > What I wonder is why line 1 and line 3 returns 8 instead of 1.
> > I guess there must be a simple solution, but I was looking into NSObject.m 
> > but did not found
> > yet, why I only get the 1 in the 2nd line.
> > 
> > If somebody could explain that, or has a pointer to documentation where to 
> > read up,
> > that would be helpful.
> 
> I guess you wonder because you misunderstood what [super class] does.
> This method call invokes the class method on the super class of the receiver, 
> i.e., on the super class of SubClass. However, the class method is 
> implemented in NSObject, which itself is a super class of SuperClass. So 
> calling [super class] is just the same as calling [self class] and will 
> return the class of the receiver (and not the receiver's super class as you 
> seem to expect).

Thanks for the explanation. It's still not logical to me, and what I'd expect, 
but if it is how it is, then I'll have to take it that way.

cheers,
Sebastian

> 
> Wolfgang
> 
 
 
 
 




reply via email to

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