手动编写代码时,我们可以通过AppDelegate 中的构造函数注入将依赖项注入到 rootViewController 中:
UIViewController *vc = [[SomeViewController alloc] initWithDependency: dependency];
self.window.rootViewController = vc;
Run Code Online (Sandbox Code Playgroud)
但是,我找不到在使用Storyboard时注入依赖项的方法。将它们注入awakeFromNib
或viewDidLoad
等等似乎是不合适的。
那可以注射吗?