Build an iOS App with a revenue 1,338$ / mo
In this part, we’re going to talk about how to inject the scenes (ViewController — UIView — SwiftUI) into our App.
If you missed the first part, you can have a look here.
Dependency Injection
We already spoke in the first part about Application Architecture and Design patterns, and how the layers should be set (Data →Domain →Presentation). So what is dependency? it is when something like a class uses some functionality of another class. We can then say that this class has a dependency on class X.
This what we are going to do next. The AppDIContainer
is a final class where its lifecycle is the same as the app and will be there as long as the app is alive. To start with this AppDIContainer
let us create an empty final class so we can create an instance of it in the AppDelegate.
let appDIContainer = AppDIContainer()
Now we can access it from the AppDelegate
.