Skip to content

Instantly share code, notes, and snippets.

@1901
Created January 24, 2013 11:26
Show Gist options
  • Save 1901/4620303 to your computer and use it in GitHub Desktop.
Save 1901/4620303 to your computer and use it in GitHub Desktop.
Objective-C获取所有的类
int numClasses = 0;
Class * classes = NULL;
numClasses = objc_getClassList(NULL, 0);
if (numClasses > 0 )
{
classes = malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
for (int i = 0; i < numClasses; i++)
{
Class cls = classes[i];
NSLog(@"[%d]:%@", i, NSStringFromClass(cls));
}
free(classes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment