Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Runtime classes enumeration #120

Open
k06a opened this issue May 31, 2016 · 4 comments
Open

Runtime classes enumeration #120

k06a opened this issue May 31, 2016 · 4 comments

Comments

@k06a
Copy link
Contributor

k06a commented May 31, 2016

@jspahrsummers can you just tell me how this lines works

if (class_respondsToSelector(class, @selector(isProxy)))

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?

@k06a
Copy link
Contributor Author

k06a commented May 31, 2016

Or you are not filtering out NSProxy subclasses?

(lldb) p [NSProxy isProxy]
NO

@k06a
Copy link
Contributor Author

k06a commented May 31, 2016

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) {
    ...
}

@jspahrsummers
Copy link
Owner

NSObject subclasses can be proxies, though.

@k06a
Copy link
Contributor Author

k06a commented Jun 4, 2016

@jspahrsummers but shouldn't this code be like this?

if (!class_isMetaClass(class) &&
    class_respondsToSelector(class_getSuperclass(class), @selector(isProxy)))
{
    keep &= ![class isProxy];
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants