0

I am seeing following error in my application. This happens when I am loading a new SubView in call back method. Below are complete details.

In my application I have RootViewController as the app launches it adds a subview called "AuthCheck". In it I perform authentication checks displaying to user details of what's happening. In the AuthCheckController I have a call back method to handle async auth process as shown below.

   - (void)shellAuthRequired: (ServiceResponse *)response {

    [super shellAuthRequired:response];

    if (response.hasError) {

        [self showTryAgainAlert: response.errorText];
        return;
    }

    // TODO: go to main screen from here.
    IntroViewViewController *intview = [[IntroViewViewController alloc]initWithNibName:@"IntroViewViewController" bundle:nil];

    //[self.navigationController pushViewController:intview animated:YES];
    [self.view addSubview:intview.view];
}

In this method as you see I forward the user to a new screen where I display necessary auth related details and the screen will have an continue button. When user clicks on "Continue" I load a new SubView called "WebViewController". Code below

       -(IBAction)btnContinueToClicked:(id)sender
{
    WebViewController *wview = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];
    [self.view addSubview:wview.view]
}

I get the exception "[IntroViewViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0xd062f50" when I add new subview to be forwarded to.

What is causing this error?

Thanks

Vish

Mr Mashabela
  • 112
  • 2
  • 10

1 Answers1

0

You're not keeping a reference to the intview object. I assume you're using ARC which means that the controller you've grabbed the view from will go away as soon as your method ends. Try making it a strong property.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57