How to get a list of all classes known to the runtime
How to get a list of all classes known to the runtime
- Subject: How to get a list of all classes known to the runtime
- From: Martin Häcker <email@hidden>
- Date: Wed, 23 Jul 2003 17:17:27 +0200
Hi there,
well, I don't know how to do this.
I was able to create this code snippet
--- snip ---
- allClasses
{
id allClasses = [NSMutableArray array];
int classCount = objc_getClassList(NULL, 0);
Class classes[classCount];
objc_getClassList( classes, classCount );
while (classCount--) {
[allClasses addObject:NSStringFromClass(classes[classCount])];
}
return allClasses;
}
--- snap ---
that lists me all the classes that are already registered with the
runtime, but:
If I write a small console application that just looks like this:
--- snip ---
#import "DWTTestCaseTest.h"
#import "DWTClassLister.h"
#include <objc/objc-runtime.h>
int main(int argc, char **argv)
{
id pool = [NSAutoreleasePool new];
// This does not list "DWTClassListerTest"
NSLog(@"%@", [[DWTClassLister new] allClasses]);
Class classListerTest = objc_lookUpClass("DWTClassListerTest");
printf("lookUp returned: '%s'\n", classListerTest->name);
// now this one does
NSLog(@"%@", [[DWTClassLister new] allClasses]);
[pool release];
return 0;
}
--- snap ---
The first time I call -allClasses I don't get "DWTClassListerTest
included in the results.
Well... The Runtime obviously knows about the class I am asking it,
because I can look it up via "objc_lookupClass", but how can I get
all of these classes without knowing their name beforehand?
Thanks for any reply,
cu Martin
--
dont.wanna.tell
[ot]coder - hehe
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.