Skip to content

Instantly share code, notes, and snippets.

@OhhhThatVarun
Created March 16, 2021 13:17
Show Gist options
  • Save OhhhThatVarun/af16422e0668923c8ac5c66b52cad619 to your computer and use it in GitHub Desktop.
Save OhhhThatVarun/af16422e0668923c8ac5c66b52cad619 to your computer and use it in GitHub Desktop.
SwDin: Simple constructor Injection example.
import UIKit
class FirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// When we want to goto the SecondViewController.
let repository = SomeRepository()
let service = SomeService()
let viewModel = ViewModel(repository: repository, service: service)
let secondViewController = SecondViewController(viewModel: viewModel)
self.present(viewController, animated:true, completion:nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment