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
| class MyViewController: UIViewController { | |
| private var associatedView = MyView() | |
| override func loadView() { | |
| self.view = associatedView | |
| } | |
| override func viewDidLoad() { | |
| associatedView.someLabel?.text = "my string value" |
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
| class MyViewController: BaseViewCodeController<MyView> { | |
| override func viewDidLoad() { | |
| associatedView?.someLabel?.text = "my string value" | |
| } | |
| } |
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
| /* ViewCode protocol */ | |
| protocol ViewCodable { | |
| func buildHierarchy() | |
| func setupConstraints() | |
| func setupConfigurations() | |
| } | |
| extension ViewCodable { | |
| func setupView() { | |
| buildHierarchy() |
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
| class BaseViewController<View>: UIViewController where View: UIView { | |
| var associatedView: View? { return self.view as? View } | |
| override func loadView() { | |
| super.loadView() | |
| self.view = View() | |
| } | |
| } |