IBOutlet becomes nil after ViewController is initialized

I have an extremely straightforward situation where an @IBOutlet in a ViewController is connected to a property in an XIB file. I've been working with iOS apps for more than ten years, and done this about a million times.

For some reason, the property becomes nil at some point after the view is loaded. I can check with the debugger to see that it is not nil at viewDidLoad, and there is nothing in my code that sets it to anything else.

I added a custom setter and getter to the variable so that I could stop in the debugger when it gets set, and the setter only gets called once, with a non-nil value.

I suspect that somehow, a different copy of my ViewController is getting instantiated, but when it does, there are no calls to any of the usual methods like viewDidLoad. In fact there is not even a call to the init method. I don't understand how this is possible.

Does this crash your app or is it working OK ?

Is the IBOutlet declared weak (as it should be) ?

Do you get the warning: Instance will be immediately deallocated because property "selectButton" is weak

AFAIU, the storyboard adds var it to the view and the view then gets a strong reference to it.

Found interesting discussion here:

IBOutlet becomes nil after ViewController is initialized
 
 
Q