Access to a pushed controller from navigationController

73 views Asked by At

I try to set some properties from a pushed viewcontroller (Viewcontroller B) to the previous view in the stack of the nav controller (Viewcontroller A).

However the object (header) I try to set properties is nil just at the moment where I set its properties. (checked with breakpoints)

ViewControllerB.m

 breapoint 1 -> ViewControllerA * missionVC = (ViewControllerA *) self.navigationController.viewControllers[n-2];



breakpoint 2 ->missionVC.header.title = companyName;
missionVC.header.subTitle = missionName;

[self.navigationController popViewControllerAnimated:YES];

at breakpoint 1, the missionVC has the header Object correctly initialized, but at the breakpoint 2 missionVC.header is nil and I don't know why.

1

There are 1 answers

0
Rajesh Maurya On

You are creating new object of previous view controller. You should pass a reference of Viewcontroller A to B and then set the value of viewcontroller A. Either you can use delegate to pass object.