discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Knowing whether a class inherits from another class


From: Marko Mikulicic
Subject: Re: Knowing whether a class inherits from another class
Date: Thu, 06 Sep 2001 02:50:53 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801

Aurelien wrote:
I think the message subject is fairly explicit...

Note that I already know how to check wether an *object* is of a class that inherits from a given class (i.e. with the isKindOf method). No, I want to have the information directly for the Class.

There was a thread about that not long time ago.
For now you should use directly GSObjCIsKindOf(Class,Class) function
because for some obscure reason isKindOf does not behave like it is expected
(I don't have a NeXT to check it out). isKindOfClass: is an OpenStep method
wich deliberatly doesn't check for inheritance if invoked for a class object.
You should use the latter for inheritance testing of objects, if you care to honor the OpenStep standard (probably macosx is not so careful about honoring compatibility with NeXTStep, AFAIK).


BTW: is there any documentation about Class ?

What kind of information you want ?
You can send messages to Class objects. First class methods
are look up then instance methods defined in NSObject.
(I hope I'm right here)
After that the illusion of Smalltalkishness falls :-)

BTW 2: I'm always sending cString messages to NSStrings when I have to format them (e.g. in an NSLog, with the %s placeholder); is there a more convenient way to do this ?

use the %@ placeholder instead of %s. It will send the "descriptionWithLocale:" or "description" message, if the former is not defined, to
that object so you can pass any object, not only NSStrings to NSLog.

Marko




reply via email to

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