Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the model? #5

Open
fabiosoft opened this issue Jul 13, 2018 · 1 comment
Open

Where is the model? #5

fabiosoft opened this issue Jul 13, 2018 · 1 comment

Comments

@fabiosoft
Copy link

In your examples i see only a viewModel with all properties... how can i declare a model class in view model and be able to bind their properties?

class PersonModel {
var name: String?
var surname: String?
}


class PersonViewModel {
var person:Person!
var completeName{
return person.name + " " + person.surname
}
}

class ViewController: UIViewController {
.
.
.

var personViewModel:PersonViewModel!
.
.
.
personViewModel.completeName = personCompleteNameTextField.text // ???
}

How can i bind (change) per model (Person) name or surname from viewModel?

@manishkkatoch
Copy link
Owner

Hello @fabiosoft, A model in MVVM is a domain object ( or a data access layer ) which takes care of persistence or retrieval of data. In the above case, PersonModel as a domain object would implement a save and a get method which PersonViewModel can use. One should be vary at what time do we commit the save as per change might be memory/network intensive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants