Closed Daemon-Devarshi closed 7 years ago
You are using Dip-UI in a wrong way. If you register view controller that should be created from storyboard you should not explicitly resolve it with container, you should create it in a usual manner - using a storyboard. Container then will resolve its dependencies with property injection. If you want to resolve view controller explicitly you should register it properly with UIStoryboard.instantiateViewController(withIdentifier:)
or with UIViewController.init(nibName:bundle:)
and view controller defined in xib.
I tried DIP in a sample app, which has two view controllers:
EmployeesViewController
- contains list viewEmployeeDetailViewController
- detail view is loaded when a cell on previous list view is selectedI am setting up the dependencies using below code:
I am trying to load EmployeeDetailViewController from
tableView:didSelectRowAt:
function as shown below:Problem is - It crashes in
EmployeeDetailViewController-viewDidLoad
due to nil IBOutlets. It works fine when I load the same view controller using standard functions.Here is the link to its codebase - DIPSample.
Am I missing anything over here? Please suggest.