The question is about MVC.
I need to check my text field changes, when user typing some text. Text field is in main view controller and I need to send changes to model function which is in another class in another swift file.
Please tell me the correct way how I can do this correct in MVC?)
What should I use in my VC and Model classes?)
2
Answers
You can check textfield changes by implementation textField delegate method
You can update model which is in different class by using delegate OR closure OR using Notification Center.
At the risk of over-stating the obvious:
MVC = Model View Controller.
Your text field is your view object.
You view controller object is your controller.
Your model is your model.
The text field delegate methods allow you view controller to collect changes from your view object and install those changes in the model. So do that. Implement
textField(_:shouldChangeCharactersIn:replacementString:)
and other methods that let the user change text) and have those methods send changes to your model via your "model function". (Your view controller will need a reference to your model object.)