I need to pass information between two view controllers I have. In the past, I have done this by importing my second view’s .h into my first view’s code, then implementing prepareForSegue in the first view and setting the values for the second view there. However, now my 2 view controllers are in a navigation controller, so there is no segue associated with the transition back to the root view controller (since it’s done with [self.navigationController popToRootViewControllerAnimated:YES]).
Is there a method similar to prepareForSegue that I can use with a UINavigationController pop? Or do I have to set up either delegates or NSNotifications to send information back to the root view?
A
pushsegue is used to transition between one view controller and the next when they are in aUINavigationController. In your StoryBoard, drag from one view to the next and choosepushas the segue type and set an identifier for the segue. Then you can setup up the destination view controller as normal.To pass information back, you will need to set up a delegate since the pushed view controller should not have detailed info about who called it.