The title pretty much says it.
I have a UITableViewController. I have some arrays I want to initialize. These have nothing to do with any views. Just pure backend data. Where should I put them?
I do not want to put them in viewDidLoad as everytime there is a memory issue, the view will be unloaded. And there is no need to do those initialization everytime a view is loaded.
Obviously not viewWillAppear.
The other places I tried was initWithCoder and awakeFromNib.
However what I observed was if I have a tabBarController with each tab having a UItableviewController, on first loading of the app, even though the selected tab is the first one, the awakeFromNib and initWithCoder is called for all other tabs.
I did not want that, because those initializations could possibly be delayed till the tab is actually selected for the first time.
Please advise.
For the combination of behaviors you are looking for I think the solution is to perform your initialization in
-viewDidLoadthus deferring it as late as possible but do so conditionally so that you do not re-initialize your arrays when the controller reloads its view.