The parentViewController property of UIViewController is readonly, but I am nesting custom view controllers and would like to use this property.
However, since it is readonly, and I found no other way to set this property, my quesion is: how do I set it?
Obviously, UINavigationController can set the property somehow in -pushViewController, and so can -presentModalViewController, so it must be possible.
I am aware that I can just add my own UIViewController property, but I'm sure that parentViewController is, in principle, the correct property.
However, since it is readonly, and I found no other way to set this property, my quesion is: how do I set it?
If it is readonly
, you can't use dot notation without getting a compiler error.
However, you might be able to use categories to add a custom modifyParentViewController
method to the UIViewController
class.
Even if the property is readonly, the variable itself might be modifiable, if it is not @protected
. If it is @protected
, subclassing the view controller may allow you the option of modifying the variable.