In MVC the Controller is the go-between for the View and the Model. So the Controller should be the one that observes or receives changes from the Model and View and updates the other accordingly. I know for sure that doesn’t break MVC.
But what if the Controller registers and unregisters the View as observer to the Model? What the view would know is the key path, what kind of change, and what the value is without having a reference to the model object. So if you assign model.title = @"new title"
the View can map that property change to an action, like a UILabel
subclass assigning self.text = @"new title"
. Does this break MVC?
4
No, having the View observe the Model (or perform other read actions on the Model) is a valid implementation of the MVC pattern.
There are two main ways that the MVC pattern is typically implemented and they differ mostly in how the information from the Model gets to the View.
In the first form, all information passes through the Controller, who is made responsible for feeding the View with the information it needs and to transform complex data structures used in the Model (like classes) into simple arrays/dictionaries that the View works with. This form is fairly popular with web frameworks with the philosophy that UX experts with limited coding experience can create the Views.
In the second form, the Controller might connect the View and the Model with each other, but the View itself determines which information to retrieve from the Model. In this form, the View can also observe the Model and be notified of changes without the Controller being involved in the update. I would expect this form more with interactive (non-web) applications.
3