Open sayHelloox opened 5 years ago
id object = objectgetClass(obj); [object aspect...]
can not work for me , What am wrong with me?
id object = object_getClass([TestObject new]);
[object aspect_hookSelector:@selector(testClassMethod) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info){
NSLog(@"Class method ------ hook");
} error:NULL];
//then call method [TestObject testClassMethod];
// No log "Class method ------ hook" print
id class = object_getClass(obj); id metaClass = objectgetClass(class); [metaClass aspect...]
import <objc/runtime.h>
fetch MetaClass Object
Class settingsMetal = objc_getMetaClass(NSStringFromClass(Settings.class).UTF8String);
hook with the MetaClass Object
NSError error = nil;
[settingsMetal aspect_hookSelector:@selector(hello:) withOptions:AspectPositionBefore usingBlock:^(id
} error:&error]; NSLog(@"error %@", error);
Hope this help you !
I find some answer like https://github.com/steipete/Aspects/issues/20 https://github.com/steipete/Aspects/issues/27, but I found those can not work, do someone have other solution, thanks!