Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created October 22, 2017 03:27
Show Gist options
  • Save azamsharp/d396f728c39c34c0dc513cb7dea76d8a to your computer and use it in GitHub Desktop.
Save azamsharp/d396f728c39c34c0dc513cb7dea76d8a to your computer and use it in GitHub Desktop.
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