Re: Getting a list of all classes, etc...
Re: Getting a list of all classes, etc...
- Subject: Re: Getting a list of all classes, etc...
- From: "Sherm Pendley" <email@hidden>
- Date: Wed, 26 Mar 2008 22:19:23 -0400
On Wed, Mar 26, 2008 at 10:01 PM, Graham Cox <email@hidden> wrote:
> Is there a way to obtain from the runtime a list of all classes that
> are subclasses of a given class, or failing that, a list of all
> classes that I can iterate and test with isKindOfClass:?
Here's the function I use in CamelBones to iterate through all registered
classes. It hasn't been updated to Leopard's new ObjC 2.0 runtime yet, but
neither have most Mac users. :-)
// Create Perl wrappers for all registered ObjC classes
void REAL_CBWrapRegisteredClasses(void) {
int numClasses;
Class *classes;
int i;
classes = NULL;
numClasses = objc_getClassList(NULL, 0);
if (numClasses > 0) {
classes = malloc(sizeof(Class) * numClasses);
objc_getClassList(classes, numClasses);
for(i=0; i < numClasses; i++) {
REAL_CBWrapObjectiveCClass(classes[i]);
}
free(classes);
}
}
sherm--
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden