在arc下使用objc_getClassList
有没有人设法使用下弧的objc_getClassList,closures文件的弧closures?
根本的问题是其中一个参数是C类指针的数组。
这个代码应该在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); }