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 (classisMetaClass(klass)) {
className = [NSString stringWithFormat:@"meta%@", className];
}
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 (classisMetaClass(klass)) { className = [NSString stringWithFormat:@"meta%@", className]; }