December 2018
Intermediate to advanced
414 pages
10h 19m
English
A really handy extension is the SwinjectStoryboard plugin, which adds Automatic Storyboard Injection to Swinject:
extension SwinjectStoryboard { class func setup() { defaultContainer.storyboardInitCompleted(WeatherTableViewController.self) { r, c in c.weatherFetcher = r.resolve(WeatherFetcher.self) } defaultContainer.register(Networking.self) { _ in Network() } defaultContainer.register(WeatherFetcher.self) { r in WeatherFetcher(networking: r.resolve(Networking.self)!) } }}
The SwinjectStoryboard class inherits from UIStoryboard and lets us inject all the dependencies in the view controllers defined in the storyboard. If the setup() class function is present, it will be called during the setup of the app, and ...
Read now
Unlock full access