Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

It would be better to use class_replaceMethod #4

Open
BlueCocoa opened this issue Aug 11, 2017 · 0 comments
Open

It would be better to use class_replaceMethod #4

BlueCocoa opened this issue Aug 11, 2017 · 0 comments

Comments

@BlueCocoa
Copy link

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.

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

1 participant