I have a custom container view controller that I instantiate from a storyboard and that has a bunch of methods that modify the content of subviews that I've set outlets to from the storyboard.
There are a bunch of ways that I might instantiate this ViewController, and at present I have to make sure that, however I instantiate it, I either display it, explicitly call loadView
, or access its .view
property before I start doing anything that uses its outlets (since they're all null pointers until loadView
is called).
Ideally, I'd like to put a call to loadView
or .view
in a single initialiser method of my ViewController
to get around this problem, rather than having to put the call to .view
in a bunch of different places where I initialise the ViewController from.
Does the UIViewController
class have a designated initialiser? If not, what methods do I need to modify with my custom initialisation logic to ensure that it will be called on initialisation of my ViewController no matter what?