Last active
May 12, 2020 22:03
-
-
Save sandeeplearner/a87f91ad17706bae64b21d1afa505165 to your computer and use it in GitHub Desktop.
Protocol with associated type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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