Re: Basic runtime function usage - objc_getClass
Re: Basic runtime function usage - objc_getClass
- Subject: Re: Basic runtime function usage - objc_getClass
- From: Francis Derive <email@hidden>
- Date: Wed, 23 Nov 2005 20:42:56 +0100
On Nov 23, 2005, at 6:23 PM, Sherm Pendley wrote:
"id" is a typedef for "objc_object*", but in fact it can be either
that or "objc_class*", [•••].
objc_getClass() returns a Class (not a Class*), but it's declared
as id so that you can easily send messages to it.
(Class, btw, is a typedef for objc_class*)
[...]
For an instance, isa points to a class definition. But for a Class
(i.e. for an objc_class struct), isa points to the metaclass,
another objc_class.
(gdb) print myPointerToClass->isa->name
There is no member named name.
-- what ? why ? No way to understand !
I'm not certain whether a metaclass has a meaningful name.
I can't think of any reason why it might need one; it's not really
useful on its own, only as a part of the class with which it's
registered.
If what you want is the name of the class, just declare
myPointerToClass as the correct type, and look at its name member
directly, for instance:
if (myPointerToClass) {
NSLog(@"%s is registered", myPointerToClass->name);
}
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Sherm,
You did it, thanks a lot. I had been a so long time confused : I did
want to reach any field like the name of the class, but nothing much
about the metaclass.
This is fine - wasn't it confusing - I keep your explanation with me
as a solid reference in my future reading the doc.
Cheers,
Francis. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden