Skip to content

Instantly share code, notes, and snippets.

@sandeeplearner
Last active May 12, 2020 22:03
Show Gist options
  • Save sandeeplearner/a87f91ad17706bae64b21d1afa505165 to your computer and use it in GitHub Desktop.
Save sandeeplearner/a87f91ad17706bae64b21d1afa505165 to your computer and use it in GitHub Desktop.
Protocol with associated type
protocol ViewControllerProtocol: UIViewController {
associatedtype viewModelType
var viewModel: viewModelType! { get set }
init(with viewModel: viewModelType)
}
extension ViewControllerProtocol {
init(with viewModel: viewModelType) {
self.init(nibName: nil, bundle: nil)
self.viewModel = viewModel
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment