We had the need to expose a UINavigationController
created by UIStoryboard
to a class that was managed by Typhoon. We were already using a technique to inject a ViewController's properties with Typhoon-managed objects, but we wanted to go the other way around and get the UINavigationController
that was created by UIStoryboard
into the Typhoon universe.
Because the UIStoryboard
(and therefore UINavigationController
) doesn't actually exist when Typhoon is doing its thing, we had to create a NavigationControllerProxy
that would look it up and return it when it was asked. This could then be injected by Typhoon into any object which neede the UINavigationController
:
// NavigationControllerProxy.m
- (UINavigationController *)navigationController {
return (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;
}