MVC for iOS
Data Models – objects that you use to maintain, manipulate and retrieve retrieve.
The data model represents the core information that your application is being used to access and manipulate.
For example, User is a piece of data. Then you would want to have a class UserDB, where you specifically have methods to pass in user data and retrieve user data from the database. All of that combined is a very basic data model. As you add more objects to represent all the information that will interact with each other, you will have a more complex data model.
The Data Model works strictly between the controller and the database storage.
They’re kinda like the warehouse guys at retail stores. A Manager would tell them what stuff they need to bring out from the warehouse and where to stock it. The bringing out of the stuff from warehouse is like data retrieving from the database. When the warehouse guys stock it, they are giving the needed data back to the controller, or managers.
Controller – A controller can send commands to the model to update the model’s state. It can also send commands to its associated view to change the view’s presentation of the model.
Essentially, its like a manager on a sales floor. Sales people let the manager know whats going on and what items has been sold out, or too much, or whatever the customers need. The manager then communicates with the warehouse guys to let them know what kind of items to bring out, take back, restock, overstock, etc.
Similarly, the controller see what the views want or request, then communicates with the data model to do it. Then gives any response back to the views.
View – These are the like the sales guys. They communicate with the customers and take care of all customer input.
The View takes in all user inputs. Then gives it to the controller to be processed.
From an iOS perspective: