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

Aspects hook firstly and later other AOP framework hook a same method, which will cause crash. #143

Open WJustin opened 6 years ago

WJustin commented 6 years ago

[[UIViewController class] aspect_hookSelector:@selector(viewDidAppear:) withOptions:AspectPositionBefore usingBlock:^(id invoke) { NSLog(@"Aspects viewDidAppear"); } error:NULL];

[AspectsSwizz swizzingInstanceMethodByClass:[UIViewController class]
originSelector:@selector(viewDidAppear:) swizzingSelector:@selector(hook_viewDidAppear:)];

UIViewController *vc = [[UIViewController alloc] init];
[vc viewDidAppear:YES];

the above code will cause exception. My resolution is the https://github.com/steipete/Aspects/pull/142