Question

I am looking for a way to assign ivar when [self.navigationController popToRootViewControllerAnimated:YES]; is called, similarly to how you can set values when a segue is called:

if ([segue.identifier isEqualToString:@"login"]) {
    [sender resignFirstResponder];
    HomeController * home = (HomeController *)segue.destinationViewController;
    home.personHome = self.person;

}

where I am assigning an objects variables. The current architecture uses [self.navigationController popToRootViewControllerAnimated:YES];

When the application loads the HomeController is the first view but in its view did Load methods it calls [self performSegueWithIdentifier:@"login" sender:self]; to go to the login screen. Successfully login in pops back.

Advice and direction is greatly appreciated.

Was it helpful?

Solution

This worked:

HomeController *myController = (HomeController *)[self.navigationController.viewControllers objectAtIndex:0];
myController.personHome =self.person ;
[self.navigationController popToViewController:myController animated:YES];

OTHER TIPS

This is how I made it work in Swift 2.2:

let myController = self.navigationController?.viewControllers[0] as! HomeController
myController.personHome = self.person
self.navigationController?.popToRootViewControllerAnimated(true)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top