I'm quite new to iOS and swift, and am running into a few problems. I know there must be some best practice here, and so would like to know the best way to do it instead of hacking at it. It may be a silly question.
I have to create a set of buttons programmatically from an array, and I do it in a ViewController.swift under viewDidLoad. I load a window and it runs "setupButtons()" and runs the setupButtons creating them in a row, as well as printing a line for each button I create. It does this every time the view loads (obviously).
Is this ok?
Should I be creating these buttons somewhere else other than ViewController I am currently in?
Does it remove the buttons (or whole ViewController) as the ViewController is changed? (as I change ViewControllers from a menu in the app for example?)
Apologies if my questions are beginner. I have tried to find solutions outside of asking questions on stackoverflow but haven't managed.