Skip to content

Instantly share code, notes, and snippets.

@bhoomesh
Created March 30, 2012 17:48
Show Gist options
  • Save bhoomesh/2253321 to your computer and use it in GitHub Desktop.
Save bhoomesh/2253321 to your computer and use it in GitHub Desktop.
Need a good list of every UIView subclass use class lister?
extern "C" {
int objc_getClassList(Class*, int);
Class class_getSuperclass(Class cls);
const char * class_getName(Class cls);
}
- (void)viewDidLoad {
int numClasses = objc_getClassList(NULL, 0);
Class *classes = NULL;
classes = (Class*)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
for(int i = 0; i < numClasses; i++) {
Class cls = classes[i];
for(Class c = cls; c = class_getSuperclass(c);) {
if(!strcmp(class_getName(c), "UIView")) {
cout << class_getName(cls) << endl;
break;
}
}
}
free(classes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment