I have a view controller with properties that determine its behavior. They are set by the parent in prepareForSegue .
The potential error that occurs in my program is that the parent in question is not guaranteed to set properties, so I would like to have a default value. In research, I now understand that Objective-C properties do not have default values. This left me with the following options:
- Set the default values โโfor the properties in the child view method
viewDidLoad . However, when investigating, viewDidLoad is called after prepareForSegue in the parent - so I would rewrite the parent values โโwhen the parent really sets the properties. - Then I thought that I could use
(id) init to initialize the values, but at least when using the storyboard this method is not called at all!
I may have a workaround in that the objects will be initialized with the default value, but in this case all I want to pass is BOOL. And since bool will have some value, even if it was not correctly initialized, I cannot check it if it is not equal to zero.
Is it possible to initialize the value in the controller of the child view to prepareForSegue in the parent?
source share