Aspects icon indicating copy to clipboard operation
Aspects copied to clipboard

this is a resolution to support hook static method

Open Assuner-Lee opened this issue 7 years ago • 4 comments

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

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

!!!!!!!

Assuner-Lee avatar Dec 28 '17 09:12 Assuner-Lee

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

[MFMailComposeViewController canSendMail]

Been looking for this for awhile!

varun531 avatar Jan 08 '18 12:01 varun531

@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!

xxfenxx avatar Feb 07 '18 05:02 xxfenxx

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

Assuner-Lee avatar Jan 15 '20 02:01 Assuner-Lee

@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

Assuner-Lee avatar Jan 15 '20 02:01 Assuner-Lee