Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
- (void)interceptSeguesToPerformDependencyInjection {
NSError *error;
id<AspectToken> DIAspectToken = [UIViewController aspect_hookSelector:@selector(prepareForSegue:sender:) withOptions:AspectPositionBefore usingBlock:^(id<AspectInfo> aspectInfo, UIStoryboardSegue *segue, id sender) {
UIViewController *destinationController = segue.destinationViewController;
[self.UIAssembly inject:destinationController];
if ([destinationController isKindOfClass:[UINavigationController class]]) {
for (UIViewController *viewController in destinationController.childViewControllers) {
[self.UIAssembly inject:viewController];
}
}
} error:&error];
if (error) {
DDLogError(@"Failed to configure view controller dependency injection: %@", error);
return;
}
self.DIAspectToken = DIAspectToken;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.