相关疑难解决方法(0)

使用storyboard时如何对第一屏的视图控制器进行依赖注入?

手动编写代码时,我们可以通过AppDelegate 中的构造函数注入将依赖项注入到 rootViewController 中:

UIViewController *vc = [[SomeViewController alloc] initWithDependency: dependency];
self.window.rootViewController = vc;
Run Code Online (Sandbox Code Playgroud)

但是,我找不到在使用Storyboard时注入依赖项的方法。将它们注入awakeFromNibviewDidLoad等等似乎是不合适的。

那可以注射吗?

dependency-injection objective-c storyboard ios

5
推荐指数
1
解决办法
1505
查看次数