Parent View Controller

Discussion in 'iOS Programming' started by idelovski, May 11, 2009.

  1. idelovski macrumors regular

    Sep 11, 2008
    I have two view controllers, one is presenting the other modally with -presentModalViewController:animated:, and the second controller has a view with a button that should close it by calling parents -dismissModalController which just cals -dismissModalViewControllerAnimated:.

    The problem is that I can't use parentViewController property of second controller to set a target for the dismissing action:
    [theButton addTarget:self.parentViewController 
    This ends with unhandled exception when I press the button.

    Then I added realParentController property and -initWithRealParent: method to the second controller and when I changed the code above to use that new property, the modal view closed ok without any unhandled exceptions.
    [theButton addTarget:self.realParentController 
    I can see in debugger while I'm in -loadView that the parentViewController property of the second controller is not nil, but why it isn't the right pointer to the parent controller?

Share This Page