How would I use Typhoon with iOS storyboards where view controllers are generated implicitly by the system? Would I have to do something special in the prepareForSegue methods?
There is a TyphoonStoryBoard component in the backlog, however it hasn't been implemented yet (see update below).
There is currently a -injectProperties: method on the component factory that you can use to apply dependency injection on a component after it has been instantiated, ex. by the story board.
For now, you could subclass UIStoryboard and call the -injectProperties: on the view controller by overriding:
– instantiateInitialViewController
– instantiateViewControllerWithIdentifier:
Example:
- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier {
id instantiatedViewController = [super instantiateViewControllerWithIdentifier:identifier];
[[TyphoonComponentFactory defaultFactory] injectProperties:instantiatedViewController];
return instantiatedViewController;
}
Update:
TyphoonStoryBoard integration has now been completed (pending documentation), and committed to master. It will be released as part of Typhoon 2.0, in the coming weeks.
It is very simple with TyphoonStoryboard
By bootstrapping Typhoon in your plist, along with the usual UILaunchStoryboardName and UIMainStoryboardFile, Typhoon will ensure that all Storyboards are an instance of TyphoonStoryboard. Use exactly as you would a normal Storyboard, with the added benefit that dependencies will be injected according to the definitions in your TyphoonAssembly class(es).
Optionally, you can specify which definition should be used for each viewController. For that, use 'typhoonKey' runtime attribute in storyboard. Otherwise the definition matching the controller class will be used. Example:
The documentation for this feature is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With