steipete / Aspects

Delightful, simple library for aspect oriented programming in Objective-C and Swift.
https://twitter.com/steipete
MIT License
8.4k stars 1.26k forks source link

类方法调用--- #147

Closed lanchc closed 3 years ago

lanchc commented 6 years ago
// #import <objc/message.h>
NSString* nameClass = NSStringFromClass(AspectsViewController.class);
Class catMetal = objc_getMetaClass([nameClass UTF8String]);
[catMetal aspect_hookSelector:@selector(hello) withOptions:AspectPositionAfter usingBlock:^(id aspectInfo){
    NSLog(@"hello");

} error:NULL];
xindizhiyin2014 commented 5 years ago

you can have a look at https://github.com/xindizhiyin2014/JKUBSAspects, it have the operation of class method hook

sayHelloox commented 5 years ago
// #import <objc/message.h>
NSString* nameClass = NSStringFromClass(AspectsViewController.class);
Class catMetal = objc_getMetaClass([nameClass UTF8String]);
[catMetal aspect_hookSelector:@selector(hello) withOptions:AspectPositionAfter usingBlock:^(id aspectInfo){
    NSLog(@"hello");

} error:NULL];

if use this method, you can not hook the instance method, it will crash, do you have more solution for hooking class method use Aspects lib, thanks!

xindizhiyin2014 commented 4 years ago

thanks,I will try later!

发自我的 iPhone

在 2020年1月15日,上午10:33,Assuner notifications@github.com 写道:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

0xjaden commented 3 years ago

you can have a look at https://github.com/xindizhiyin2014/JKUBSAspects, it have the operation of class method hook

照抄一份加前缀有意思?