- Modal Model objects:
Model objects encapsulate the application's data and define the logic and operations that manipulate and manipulate the data. For example, a model object might be a list that represents a commodity data. The actions that the user creates or modifies data in the view layer are communicated through the Controller object and eventually the model object is created or updated. When a model object changes (for example, new data is received over a network connection), it notifies the controller object that the Controller object updates the corresponding View object.
- View View object:
A View object is an object that the user can see in the application. The View object knows how to draw itself and may respond to the user's actions. The primary purpose of a View object is to display data from an application model object and make that data editable. However, in an MVC application, the View object is usually detached from the model object.
In iOS application development, all controls, windows, and so on are inherited from UIView, corresponding to the V in MVC. UIView and its subclasses are responsible for the implementation of the UI, and the events generated by UIView can be entrusted to Uiviewcontroller.
- Controller Controller object:
A Controller object acts as a medium between one or more view objects and one or more model objects in an application. The Controller object is therefore a synchronous pipe program through which the view object understands changes to the model object, and vice versa. The Controller object can also perform settings and reconcile tasks for the application and manage the life cycle of other objects.
The Controller object interprets user actions in the View object and communicates new or changed data to the model object. When a model object changes, a controller object communicates the new model data to the View object so that the view object can display it.
For different UIView, there are corresponding uiviewcontroller, corresponding to the C in MVC. For example, the UITableView used on IOS, the Controller that corresponds to it is uitableviewcontroller.
In actual development, M is usually understood as the database operations layer, although it is intended to be a business model.
V is the interface layer, this is no objection.
C is understood as the business layer.
1) Model and View can never communicate with each other and can only be passed through the Controller.
2) controller can talk directly to model (read and write call model), model through Notification and KVO mechanism to communicate with Controller indirectly.
3) The controller can directly manipulate the View,outlet directly to the control in the view through outlet, directly to the view, and the view reports the event to the Controller via action (as the user touches me). The controller is the direct data source of the View (the data is most likely the controller has been obtained from the Model and processed). The controller is the proxy for the view (delegate) to synchronize the view with the controller.
- M Layer model (more of a database model)
(1) Create a database, create the appropriate table
(2) Complete the operation of adding, deleting, changing and checking the tables of the database
(3) The entity classes that map the various tables of the database (the role of this entity class is to communicate the bridge between the database layer (M) and the control layer (C), and this entity class will also be responsible for its background data (XML, Sbjson, etc.) and local data communication and storage)
features to be implemented in this layer :
The increase, deletion, modification and investigation of various tables in the database
- C Layer Control
The meaning of this layer is to ensure the synchronization of M and V. I personally understand that this layer is not only called the control layer, but also should be called the business layer.
Features to be implemented in this layer:
Data and events in interface controls
- V Layer View
Needless to say, in iOS, this layer is mostly done by the. xib file. If the customer is a custom requirement, it is implemented in the. m file. The function that this layer implements is the layout of the control.
The MVC model for iOS learning