discuss-gnustep
[Top][All Lists]
Advanced

[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: Fri, 10 May 2002 12:02:32 +0100 (BST)

> > I would appreciate this. I don't know exactly but I don't think this is 
> > OPENSTEP spec. A dictionary responding to -name sounds a bit weird to 
> > me. I will probably not be(stay) the only one that gets caught by this.
> 
> Umm, isnt the 'name' method on a class actually part of the objective
> C runtime ?

Yes - you are right - it is defined in the GNU libobjc for the class
Object.

Since no GNUstep class inherits from Object, dropping it means gnustep
objects would no longer respond to -name - which I think it's a very good
thing, because it's too generic a method name not to get in the way of
someone at some point.

But yes - some sort of `compatibility' with objects inheriting from Object
is lost.  But I'm not sure if anyone is using that.


> I wrote my own foundation library at one point and I use 'name' in order
> to print the name of a class. I dont know of any other way of doing it 
> in fact.

With the GNU runtime,

const char *name = object_get_class_name (class);

and with the Apple runtime, something different but likely very similar -
if I remember correctly, something like const char *name =
object_getClassName (class);.

If on top of a Foundation library, 

NSString *string = NSStringFromClass (class);

which is the portable way of doing it.




reply via email to

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