I’m making a settings menu in my application, and so far I’m making separate view controller for every screen. Is this a correct way of doing that? It grows very fast, and I am not sure it is an optimal way. For example, I have:
UINavigationViewControllerthat is main controller of settings tab.- Under it I have
UITableViewControllerthat shows main settings screen. - When I click any settings cell in the middle, it sends me to its own view controller.
- And I need different models to keep every part of every view controller settings separate, or can I just fill them up into one file?
And as I have many customizable settings, do I really need separate view controller for every settings button? This looks overly complicated.
This will depend to some extent on the specific types of settings that you need. For simple on/off settings you can use a
UISwitchcontrol directly in your mainTableView(see Airplane Mode in the main Settings app as an example).For any other types of settings that are similar you can use a single generic view controller that is passed the necessary parameters for each setting. For example, maybe you have five different settings that all involve picking one item from a list. These could all call the same controller, passing an array of choices and a reference to the parameter rather than recreating essentially the same view five times.
By doing this and also grouping related settings into a single view (again, see the main Settings app for examples), you should be able to keep the number of necessary controllers to a minimum.