Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vcanic

macrumors newbie
Original poster
Feb 4, 2010
13
0
Hello,

The last couple of weeks I have been reading a lot of tutorials on how to design your application (regarding ViewControllers0 when starting to code on the iPhone.

Two different examples examples:

- Within your appDelegate define a RootViewController/MainViewController that instantiates all your other ViewControllers. All these ViewControllers are added to the window (MainWindow.xib). So this makes appDelegate and the MainWindow 'all-knowing' if it comes to the ViewControllers and their associated Views.
I would assume that this is really memory consuming.

- Instantiate your ViewControllers and their associated Views as you go. So your appDelegate and window (MainWindow) will only know 1 ViewController and that ViewController knows it's child and so on. For example:
LoginViewController --> CustomerViewController --> CreatedCustomerViewController etc.
I would assume that this is much more efficient.

My question is: What is the best way on going to programming and designing your application when choosing one of those examples? Or are there other and better ways?

Some tips would be much appreciated. Thanks in advance.
 
Hello,

The last couple of weeks I have been reading a lot of tutorials on how to design your application (regarding ViewControllers0 when starting to code on the iPhone.

Two different examples examples:

- Within your appDelegate define a RootViewController/MainViewController that instantiates all your other ViewControllers. All these ViewControllers are added to the window (MainWindow.xib). So this makes appDelegate and the MainWindow 'all-knowing' if it comes to the ViewControllers and their associated Views.
I would assume that this is really memory consuming.

- Instantiate your ViewControllers and their associated Views as you go. So your appDelegate and window (MainWindow) will only know 1 ViewController and that ViewController knows it's child and so on. For example:
LoginViewController --> CustomerViewController --> CreatedCustomerViewController etc.
I would assume that this is much more efficient.

My question is: What is the best way on going to programming and designing your application when choosing one of those examples? Or are there other and better ways?

Some tips would be much appreciated. Thanks in advance.

I usually just use the View app template in XCode. If I need a tab bar controller or navigation controller, I'll declare that in the App Delegate rather than another view controller, and I'll just push more views onto the stack when I need to (with nav controller).
 
I usually just use the View app template in XCode. If I need a tab bar controller or navigation controller, I'll declare that in the App Delegate rather than another view controller, and I'll just push more views onto the stack when I need to (with nav controller).

Does this mean that you only use the "nav controller" for pushing views onto the stack and nothing else?

Also, in this case all your controllers are instantiated within the App Delegate?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.