I have read several resources so far about MVC design pattern for iPhone application development. However I have one question related Model part of MVC in iPhone development context.
Firstly, I would like to say what I think of MVC,
Model : is related to a data which we have regarding our application's objects. Example : Application of a Train simulator than, Each train on simulation will be having it'e own attributes and that will be saved inside Train model.
Controller : is something which controls UI updates. It keeps a reference to Train model and checks for any changes in model, If there is than change the View of that particular train. And it keeps checking for any UI input so it can change data inside Model.
View : This is fairly obvious View is all about UIView, What we see on screen.
Now, Question is...
Does Model has to be persistent to be considered as a Model? or I can have a Class which has variables without any persistency. Would that be considered as Model as well, Or Model must be stored somewhere like in CoreData or .Txt file etc....
Thanks for any input!
Does Model has to be persistent to be considered as a Model?
It may vary or transform as long as your controller can support it.
Model must be stored somewhere like in CoreData or .Txt file
Not at all.
You can use any Model if applicable. Model is just another abstraction of your actual logic/database/network access/blablabla...
No, the idea behind MVC does not actually relate to databases, although that is usual. The model simply should capture all the business logic. If you are building a calculator, view is the display and the buttons, model is the part of code that knows how to add and subtract, and controller is the one that connects the two. No persistence involved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With