Skip to content

When exchanged a class method after a instance method exchanged, the class method will be invalid #140

@leverkusen123

Description

@leverkusen123

For example, I've hooked the instance method of class A.
Then I try to hook another class method of class A, this class method will be invalid.

I've reviewed the code and find the issue here.
*_aspect_modifySwizzledClasses(^(NSMutableSet swizzledClasses) {
if (![swizzledClasses containsObject:className]) {
aspect_swizzleForwardInvocation(klass);
[swizzledClasses addObject:className];
}
});

The names of class and metaclass are the same. So the aspect_swizzleForwardInvocation of metaclass hook won't be invoke....

Easy to fix this.
Add following code before aspect_modifySwizzledClasses.
if (class_isMetaClass(klass)) {
className = [NSString stringWithFormat:@"meta
%@", className];
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @leverkusen123

        Issue actions

          When exchanged a class method after a instance method exchanged, the class method will be invalid · Issue #140 · steipete/Aspects