I perform a segue which is defined in the Storyboard to open a new view controller. I need to configure the destination view controller of the segue in a special state where some of it's buttons does not needed to be displayed.
I know that I can do this by setting a variable on this controller in my source view controller's -prepareForSegue:sender:
. The problem with this is, that firstly it instantiates the controller, so it's -viewDidLoad:
will run, then only after can I set anything on it.
I can't create the controller entirely from code, because it's user interface is in Storyboard. -instantiateViewControllerWithIdentifier:
also calls -viewDidLoad
first obviously.
I could probably use a semaphore and add the initialization code into my destination controller's -viewWillAppear
, but that's ugly, it has to be some more elegant way to do this than doing a check every time the view appears. (My settings need to be done only once.)
Is there some way to pass variables into the controller before it's -viewDidLoad
runs?
EDIT: It looks like this happens only if I trigger the segue from code using -performSegueWithIdentifier:
.