Note that there are some explanatory texts on larger screens.

plurals
  1. POXcode 4 organization, Views and Controllers
    text
    copied!<p>Thank you for reading this.</p> <p>These are my first steps in the iPhone Ipad app programming. In order to learn from scratch (and because I know my app would need dynamic views), I decided not to use Interface Builder.</p> <p>My question is(regarding the fact that I don't use IB): how would one use Views and Controllers?</p> <p>I think I understand the MVC concept as it is repeated over and over again in the tutorials I follow, but after the "MVC explanation" part, nothing is made to make it clear "on the field" and closer to the real world (Earth being Xcode here). Worse, sometimes it seems that some tutorials mix these two concepts up and use one word to say the other.</p> <p>I read around here a lot of questions (and answers of course) based on the matter but I still don't get it. Sometimes it's too generic, sometimes it's too specific (for me at least).</p> <p>For what I think I understood, the UIView is the static View when the View Controller is the logic which links the View to the data and those 3 concepts must be separated. This separation, while a bit clearer with the use of Interface Builder seems to get quite blurry when you code everything as it becomes a virtual soup.</p> <p>Technically, should I create a specific ".h" and ".m" file for each View AND ALSO for each associated Controller? If I understand the MVC pattern, it's seems that I should but when I follow tutorials (without IB) it is never the case, view and controllers are created and manipulated within the same implementation files.</p> <p>Any high level (I'm a noob, don't forget) but still applicable explanation of the use and best practices?</p> <p>Let's say I want to create a simple app with a green view I can swipe to get to a red view. I know for sure that I would need at least an:</p> <ul> <li>xxxappDelegate.h</li> <li>xxxappDelegate.m</li> <li>xxxView.h</li> <li>xxxView.m</li> </ul> <p>What else?</p> <p>1)Where should I put the the second view (along with the first one in "xxxView" or should I create another class h and m file?)?</p> <p>2) What would the controller(s) do, for that kind of application? In which files would they be created and in which files would they be invoked and how would they "control" the related view?</p> <p>3) Mainly, regarding to MVC pattern and the fact that there would be no IB, how would you organize that app?</p> <p>I know it's a lot if you go into the details and code but that's not the point here.</p> <p>Thank you. This - as simple as it seems - would be of a great help and is not as easily found in tutorials as you might think. I understand the tutorials I read but they are so particular. As soon as I try to create something on my own which is not a "Hello World" screen, I realize that something is missing, logic wise.</p> <p>Thank you very much for your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload