codesourse/BigBang

It would be better to use class_replaceMethod

BlueCocoa opened this issue · 0 comments

class_addMethod(hookClass, @selector(forwardInvocation:), forwardInvocationImpl, "v@:@");

If the class has overridden the -[WhateverClass forwardInvocation:] method, then calling the class_addMethod function will lead to fatal error. However, class_replaceMethod will act like class_addMethod if there isn't such -[WhateverClass forwardInvocation:] method, or replace the method as expected if there is one.