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]));
const char *classname = class_getName(classes[i]);
Class cls = objc_getClass(classname);
for (int i = 0; i < numClasses; i++) {
NSLog(@"Class name: %s", class_getName(classes[i]));
const char *classname = class_getName(classes[i]);
Class cls = objc_getClass(classname);
// if ( class_getSuperclass(class) == [GPUImageFilter class] || class_getSuperclass(class) == [GPUImageFilterGroup class] ) {
// [filterList addObject:class];
// }
if ([cls isSubclassOfClass:GPUImageFilter.class]) {
NSLog(@"yes");
}
}
free(classes);
}
报错[ isSubclassOfClass:]: message sent to deallocated instance,网上搜了一大堆,找不到答案,有知道的烦请交流一下。我想遍历所有类,找到某个类的所有子类。runtime也有不靠谱的时候,一般来说抱message sent to deallocated instance 是对象被释放了,这个时候还在用造成的。就这么点代码,怎么会造成过多释放?很是费解。