In Xcode, the Utility Application template makes a project with:
MainView, MainViewController
and
FlipsideView, FlipsideViewController
In my app, the two views correspond to the main UI and a preferences screen. Obviously I want the prefs to be reflected in the main UI and persisted to disk to remember settings. I know how to do that part.
The issue is, while looking at sample code of similar apps, I see that some put most of the active code in a View, leaving the ViewController little more than a stub, yet some others do it the other way around.
Is there a rule of thumb to go by when deciding where to put the bulk of my functionality?
One way to decide: if your app gets a low-memory warning, the default behavior is that any view that isn't currently visible may be destroyed. This means that if you have any state information that you can't easily re-create, you'd better not keep it in your view.
So it depends what the bulk of your functionality is doing: if it's maintaining information that the user created, it needs to be in the view controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With