Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
I have a question related to the MVC pattern. From reading the apple docs i actually started to fully understand the whole methodology about MVC design patters. So my questions are
1) Since we have a Model, View and a View Controller. Is it better practice to have a one to one relationship between those objects? So for every view controller there will be one model and one view.
or
2)Will i have one view controller that has many models and many view controllers. And when the view controller responds to a touch event of some sorts in that block il just write an if statement saying
It would be extremely limiting if there was a 1:1 relationship for these items.
The view controllers job is to mediate between the view(s) and the model(s). The view controller manages a single root view, but that view can contain any number of subviews.
Then there are view controller managers such as tab bar controllers and navigation controllers. They coordinate multiple view controllers.
Ok maybe i didn't explain my situation clearly enough, that always helps lol. Say i make a CustomViewController that derives off of UITableViewController. I know that this controller is my root controller for my program and it will show different views after this one. So my user then presses on one of the rows in the tableview and now i need to display another view showing the content of the which row my user has chosen. So now i want to display another view. If I use a one-to-many relationship between the 2 objects. All my code that will control the user experience after the user presses the row will be controller by the rootViewController. Which mean that in that controller i would just say in one of my blocks of code.
if(view1 is on screen){ //do this } else if(View 2 is on screen){ //do that }
In a one to one relation ship i would just load up an entire new view controller when the user chooses one of the rows and all the user interactivity would take place there. I hope this helps with my question
You might also want to have a quick look at patterns like Model-View-Presenter before you get started.
MVC is one of those patterns that sounds great but rarely pans out in real life. The basic problem is that strict MVC assumes a very dumb view which blindly displays data, but in real applications, the display logic can often be complicated.
MVP, for example, replaces the controller with a "presenter". There are many versions of this pattern, but MVP basically recognizes that display logic can be complicated and says it's ok to put 'complicated' display logic in the presenter, so the presenter can handle some data formatting before passing data to the view.
In my experience with business apps, the most important thing is to have a clear separation of the model from the rest; this helps testability and correctness.
Replies
The view controllers job is to mediate between the view(s) and the model(s). The view controller manages a single root view, but that view can contain any number of subviews.
Then there are view controller managers such as tab bar controllers and navigation controllers. They coordinate multiple view controllers.
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeIn a one to one relation ship i would just load up an entire new view controller when the user chooses one of the rows and all the user interactivity would take place there. I hope this helps with my question
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeMVC is one of those patterns that sounds great but rarely pans out in real life. The basic problem is that strict MVC assumes a very dumb view which blindly displays data, but in real applications, the display logic can often be complicated.
MVP, for example, replaces the controller with a "presenter". There are many versions of this pattern, but MVP basically recognizes that display logic can be complicated and says it's ok to put 'complicated' display logic in the presenter, so the presenter can handle some data formatting before passing data to the view.
In my experience with business apps, the most important thing is to have a clear separation of the model from the rest; this helps testability and correctness.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome