Hard Objc-Runtime question: objc_getClassList lies to me...
Hard Objc-Runtime question: objc_getClassList lies to me...
- Subject: Hard Objc-Runtime question: objc_getClassList lies to me...
- From: Martin Häcker <email@hidden>
- Date: Thu, 24 Jul 2003 18:34:59 +0200
Hi there,
First, please vorgive the repost, but I fear that my last e-mail was
so badly written that nobody wanted to answer to it...
well, how do I get the runtime to give me a list of all its classes?
That is, not just the ones that this code snippet gives me?
--- 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 ---
My problem is that when I write a simple testcase 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"
// (I think that is because it's not called anywhere)
NSLog(@"%@", [[DWTClassLister new] allClasses]);
// But this works perfectly
Class classListerTest = objc_lookUpClass("DWTClassListerTest");
printf("lookUp returned: '%s'\n", classListerTest->name);
// now this one does does list the class in question
NSLog(@"%@", [[DWTClassLister new] allClasses]);
[pool release];
return 0;
}
--- snap ---
The first time I call -allClasses I don't get "DWTClassListerTest
included in the results, though it works after the call to
objc_lookUpClass. :(
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?
I fear I must be missing something simple here...
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.