Has anybody managed to use objc_getClassList under arc, short of turning arc off for the file in question?
The fundamental problem is that one of the parameters is a C array of Class pointers.
This code should work under ARC:
int numClasses;
Class *classes = NULL;
classes = NULL;
numClasses = objc_getClassList(NULL, 0);
NSLog(@"Number of classes: %d", numClasses);
if (numClasses > 0 )
{
classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
for (int i = 0; i < numClasses; i++) {
NSLog(@"Class name: %s", class_getName(classes[i]));
}
free(classes);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With