3
votes

I am implementing custom UIViewController subclasses that emulate behaviours of UITabBarController and UINavigationController.

I would like to make these classes general enough so that any UIViewController can be used. One problem that I ran into is that the property parentViewController (as well as navigationController) is read only.

(Aside: One motivation for setting parentViewController is for the correct behaviour of -presentMoviePlayerViewControllerAnimated:. UIViewController seems to pass it onto parentViewController, if set.)

Using KVC method setValue:self forKey:@"parentViewController" seems to work, but could this get my app rejected? Has anyone done anything similar?

2

2 Answers

0
votes

I wouldn't worry about rejection, but I would worry about whatever motivation that Apple had for making parentViewController read-only to begin with. They might be depending on that, and you might be introducing a subtle bug.

For example -- if it's not nil at the time you set it, who is calling release on the previous value. Could these properties be passed somewhere else (and held) before you overwrite them?

If you feel confident that you aren't introducing a subtle bug, then it should be fine. Check updates to iOS in a timely manner to make sure that things haven't changed.

0
votes

I can't speak for that exact situation but from what I know and have heard, I don't think this should be a problem.