December 2018
Intermediate to advanced
414 pages
10h 19m
English
We have already agreed that Construction Injection is the best way to do DI, so why bother finding other methods?
Well, it is not always possible to define the constructor the way want. A notable example is doing DI with ViewControllers that are defined in storyboards. Given we have a BasketViewController that orchestrates the service and the store, we must pass them as properties:
class BasketViewController: UIViewController { var service: BasketService? var store: BasketStore? // ...}
This pattern is less elegant than the previous one:
Read now
Unlock full access