When a view controller is first instantiated, it usually creates or
loads objects it needs through its lifetime. It should not create
views or objects associated with displaying content. It should focus
on data objects and objects needed to implement other critical
behaviors.
The above is from the iOS reference :
The documentation goes on to describe a view load sequence with Storyboard.
My question are :
1
Since a view controller would be associated with a nib file, which contains view objects; And its “viewDidLoad” method seems to be designed for configuring view objects at load time. So how should the documentation’s suggestion :
“should not create views or objects associated with displaying content”
be interpreted ?
2
Does question 1 related to whether we use Storyboard or not ?
Not sure I get your question right, but here’s my explanation:
initialization and view creation are two separate steps. Let’s say I have a view controller with table asIBOutletwhich should display a list of recipes stored in core data. In my initialization method I’d fetch the data from CoreData and store it in an array or fetched results controller. I don’t need table for that, hence I do nothing withself.viewproperty (which calls theviewDidLoadif there is no view yet). InviewDidLoadI call[tableView reloadData]to redraw the cells so that they display the data from my controller created in controller’s initializer.I don’t think it’s related, but storyboard should be mere scaffold for your view controllers replacing separate nibs with single file.