Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this is a resolution to support hook static method #133

Open
Assuner-Lee opened this issue Dec 28, 2017 · 4 comments
Open

this is a resolution to support hook static method #133

Assuner-Lee opened this issue Dec 28, 2017 · 4 comments

Comments

@Assuner-Lee
Copy link

  1. get meta-Class from class :
    Class cls = object_getClass(self.class);

  2. hook:
    [cls aspect_hookSelector:selector withOptions:options usingBlock:block error:error];

!!!!!!!

@varun531
Copy link

varun531 commented Jan 8, 2018

Nice work @Assuner-Lee , I can confirm this works! I used it to swizzle:

[MFMailComposeViewController canSendMail]

Been looking for this for awhile!

@xxfenxx
Copy link

xxfenxx commented Feb 7, 2018

@Assuner-Lee @varun531 If had hooked a static method using the above method, then you try to hook a instance method and call the instance method, it would be crashed!

@Assuner-Lee
Copy link
Author

May you can also try Stinger https://github.com/eleme/Stinger

@Assuner-Lee
Copy link
Author

@Assuner-Lee @varun531 If had hooked a static method using the above method, then you try to hook a instance method and call the instance method, it would be crashed!

May you can also try Stinger https://github.com/eleme/Stinger

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

No branches or pull requests

3 participants