Runtime classes enumeration
@jspahrsummers can you just tell me how this lines works https://github.com/jspahrsummers/libextobjc/blob/371b8da18f163a8f7f8925ad6d592d7b3b82ad05/extobjc/EXTRuntimeExtensions.m#L354
BOOL keep = YES;
if (keep)
keep &= class_respondsToSelector(class, @selector(methodSignatureForSelector:));
if (keep) {
if (class_respondsToSelector(class, @selector(isProxy)))
keep &= ![class isProxy];
}
How do you call + (BOOL)isProxy, where this method is defined? But you only check that instances of class class responds to selector isProxy. Checking - (BOOL)isProxy but calling + (BOOL)isProxy?
Or you are not filtering out NSProxy subclasses?
(lldb) p [NSProxy isProxy]
NO
Just did some measures, looks like class_getSuperclass works a lot faster than class_respondsToSelector, this version of checking for NSObject subclass is a lot faster (more than 10x times):
Class superclass = class;
while (superclass && superclass != [NSObject class]) {
superclass = class_getSuperclass(superclass);
}
if (superclass) {
...
}
NSObject subclasses can be proxies, though.
@jspahrsummers but shouldn't this code be like this?
if (!class_isMetaClass(class) &&
class_respondsToSelector(class_getSuperclass(class), @selector(isProxy)))
{
keep &= ![class isProxy];
}