Skip to content

Instantly share code, notes, and snippets.

@ramakser
Created March 29, 2016 20:23
Show Gist options
  • Save ramakser/aa7019e949cdab78da249266771f249f to your computer and use it in GitHub Desktop.
Save ramakser/aa7019e949cdab78da249266771f249f to your computer and use it in GitHub Desktop.
- (UITabBarController *)mainViewController {
return [TyphoonDefinition withClass:UITabBarController.class configuration:^(TyphoonDefinition * definition) {
[definition injectMethod:@selector(setViewControllers:animated:) parameters:^(TyphoonMethod * method) {
[method injectParameterWith:[self mainViewControllers]];
[method injectParameterWith:@NO];
}];
}];
}
- (NSArray *)mainViewControllers
{
return [TyphoonDefinition withClass:[NSMutableArray class] configuration:^(TyphoonDefinition *definition) {
[definition injectMethod:@selector(addObject:) parameters:^(TyphoonMethod *method) {
[method injectParameterWith:[self navigationControllerWith:self.ordersViewController]];
}];
[definition injectMethod:@selector(addObject:) parameters:^(TyphoonMethod *method) {
[method injectParameterWith:[self navigationControllerWith:self.offersViewController]];
}];
}];
}
- (UINavigationController *)navigationControllerWith:(UIViewController *)controller {
return [TyphoonDefinition withClass:UINavigationController.class configuration:^(TyphoonDefinition * definition) {
[definition injectProperty:@selector(viewControllers) with:@[
controller
]];
definition.scope = TyphoonScopePrototype;
}];
}
- (TTOrdersViewController *)ordersViewController {
return [TyphoonDefinition withClass:TTOrdersViewController.class configuration:^(TyphoonDefinition * definition) {
//some injections
}];
}
- (TTOffersViewController *)offersViewController {
return [TyphoonDefinition withClass:TTOffersViewController.class configuration:^(TyphoonDefinition * definition) {
//some injections
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment