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

Error: viewDidLoad already hooked in TestViewController. A method can only be hooked once per class hierarchy. #180

Open coooliang opened 1 year ago

coooliang commented 1 year ago
@interface TestViewController : UIViewController

@interface ViewController : UIViewController

 Class class = NSClassFromString(@"TestViewController");
[class aspect_hookSelector:@"viewDidLoad" withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo) {

} error:nil];

Class class = NSClassFromString(@"ViewController");
[class aspect_hookSelector:@"viewDidLoad" withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> aspectInfo) {

} error:nil];

error: Aspects: Error: viewDidLoad already hooked in TestViewController. A method can only be hooked once per class hierarchy.

Frizlab commented 1 year ago

Ha! So this is a bit of a shameless plug, but my eXtenderZ lib does not have this limitation. Sadly I cannot recommend it as-is: it works perfectly but has close to no documentation… and my company is currently not interested in allocating me time to make the doc.

If you’re adventurous and want to use it anyway I’d be happy to help get you started!