Build an iOS App with a revenue 1,338$ / mo

A full tutorial will walk with you step by step [Part 2]

Dependency Injection

From https://www.freecodecamp.org/
let appDIContainer = AppDIContainer()
UML App diagram

Splash Screen

Splash Screen
protocol SplashViewControllersFactory {func makeDashboardViewController() -> UIViewControllerfunc makeInAppPurchaseViewController(dismissable: Bool, delegate: PurchaseDelegate) -> UIViewController}

Scene Dependency Injection

final class VPNSceneDIContainer {
func makeNetworkVPNManagerRepository() -> DVPNRepository {
return DefaultVPNRepository(vpnManager: DefaultVPNManager())
}
func makeNetworkVPNUseCase() -> NetworkVPNUseCase { return DefaultNetworkVPNUseCase(vpnManager: makeNetworkVPNManagerRepository()) } func makeDashboardViewModel() -> DashboardViewModel { return DefaultDashboardViewModel(networkVPNUseCase: makeNetworkVPNUseCase())
}
}
extension VPNSceneDIContainer: SplashViewControllersFactory {/* Splash View */
func makeSplashViewController() -> UIViewController {
return SplashViewController.create(splashViewControllersFactory: self)
}
/* Dashboard View */func makeDashboardViewController() -> UIViewController { return DashboardViewController.create(viewModel: makeDashboardViewModel(), dashboardFactory: self)}func makeInAppPurchaseViewController(dismissable: Bool, delegate: PurchaseDelegate) -> UIViewController {
reutrn UIViewController()
}
}
class SplashViewController: UIViewController, StoryboardInstantiable {
final class func create(splashViewControllersFactory: SplashViewControllersFactory) -> SplashViewController {
let view = SplashViewController.instantiateViewController()
view.splashViewControllersFactory = splashViewControllersFactory return view
}
}
func makeVPNSceneDIContainer() -> VPNSceneDIContainer {
let dependencies = VPNSceneDIContainer.Dependencies()
return VPNSceneDIContainer(dependencies: dependencies)
}

Root View Controller

var window: UIWindow?window = UIWindow(frame: UIScreen.main.bounds)let vpnLauncherViewController = appDIContainer.makeVPNSceneDIContainer().makeSplashViewController()window?.rootViewController = vpnLauncherViewControllerwindow?.makeKeyAndVisible()

Software Developer, Tech enthusiastic, iOS #swift \\ Android #kotlin

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store