It's a generic ques开发者_JAVA技巧tion and really a newbie one too, so bear with me...
I'm playing with some iPhone development, and trying to create a simple "flip type" application. Nothing sophisticated, let's say on the flip side is a short application summary, bit like 'help' and on the main screen is a simple board game, let's say tic-tac-toe or similar.
Now, XCode has generated me 'Main View', 'Flipside View' and 'Application Delegate' folders, with default template files in them.
Now the question is where do I create appropriate 'MVC' classes?
Let's say (V)iew classes are going to be the ones that have been automatically created. So the Flipside view class is responsible for generating text/images etc on the 'help' view.
'Main View' class is what draws the items on the table and updates the counters, etc.
Where should I place the 'controller' class? And also, should it only be dealing with proxying only to the model? According to this the controller method is called from the view and manipulates the method classes. Similarly, the results from model are passed back to the view class by the controller issuing the calls to appropriate view methods.
Similarly, where does the model class go? or should I just create a new folder for each, controller and model class files?
What I'm after is the best practices, or just a short description how people normally structure their applications. I know it's very specific and also undefined... I came from Django background, so the way stuff is organised there is slightly different.
Hope this makes sense, sorry if it's all bit vague, but I have to start somewhere :) And yes I've read quite few docs on the apple developer site, but trouble is that the documents are either going into too much detail about the language/framework/etc and the examples are way too simplistic. Actually, this leads me to the final question, has anyone know any good example of relatively complete application tutorial which I could use as a reference in organising my files?...
UPDATE: I was looking at this as an example. But what happens there, is that all game variables, such as ball speed etc are store in the view controller class. So basically embedding the model into controller. And what about the View? there's no View classes there (nor in the default XCode created project), should I assume that the View == NIB? If so, then where do I create objects programatically? Is that supposed to happen in the controller?
Go check out the Apple code examples. If that was the examples you are referring to maybe these examples can help clarify. The example applications are nice since Apple is the supreme commander on this platform so there is no doubt wether or not it's the correct way to do something.
Remember to click the "download sample code" button since reading code without syntax highlighting makes it harder then it has to be.
Im no expert myself but I think about it as Core Data (M) - NIB's(V) - ViewController(C).
精彩评论