Created
May 16, 2016 13:38
-
-
Save craigmarvelley/3e479a9c7d9e7724790afe99c04e7855 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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