#import <objc/runtime.h>
#import <dlfcn.h>
#import <mach-o/ldsyms.h>
unsigned int count;
const char **classess;
Dl_info info;
dladdr(&_mh_execute_header, &info);
classess = objc_copyClassNamesForImage(info.dli_fname, &count);
for (int i = 0; i < count; i++) {
NSLog(@"Class name: %s", classess[i]);
Class class = NSClassFromString ([NSString stringWithCString:classess[i] encoding:NSUTF8StringEncoding]);
// Do something with class
}
int numClasses;
Class * classes = NULL;
classes = NULL;
numClasses = objc_getClassList(NULL, 0);
if (numClasses > 0 )
{
classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
for (int i = 0; i < numClasses; i++) {
Class c = classes[i];
NSLog(@"%s", class_getName(c));
}
free(classes);
}