Created
October 22, 2017 03:27
-
-
Save azamsharp/d396f728c39c34c0dc513cb7dea76d8a to your computer and use it in GitHub Desktop.
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 AddArticleViewController : UIViewController { | |
// For this example assume they are UITextField | |
@IBOutlet weak var titleTextField :BindingTextField! | |
@IBOutlet weak var descriptionTextField :BindingTextField! | |
var viewModel :AddArticleViewModel! { | |
didSet { | |
viewModel.title.bind = { [unowned self] in self.titleTextField.text = $0 } | |
viewModel.description.bind = { [unowned self] in self.descriptionTextField.text = $0 } | |
} | |
} | |
@IBAction func AddArticleButtonPressed(_ sender: Any) { | |
self.viewModel.title.value = "hello world" | |
self.viewModel.description.value = "description" | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.viewModel = AddArticleViewModel() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment