Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC in iPhone development context

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.

enter image description here

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!

like image 247
TeaCupApp Avatar asked Oct 21 '11 00:10

TeaCupApp


2 Answers

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...

like image 91
ZhangChn Avatar answered Sep 21 '22 16:09

ZhangChn


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.

like image 44
Amadan Avatar answered Sep 20 '22 16:09

Amadan