Because I wanted to see how I can do "real" MVVM, that dynamically exchanges data between view and model (not, as in most examples, only sends data to view).
In addition it's a real-world example of Swift 4 key path usage.
Project is divived in 4 groups, to keeps things simple:
- Binding -
KeyPathBinding, for simplicity it handles onlyStringdata types - Model -
Credentialsmodel (with 2 string fields) - ViewModel - you should do all model and view operation via
LoginViewModelclass - Controller - in which you bind
UITextFieldsto our view model
This example works for structs, however each binding creates it's own struct copy.