I have a navigationcontroller with two view on storyboard.
In the first view I use this to navigate to the next (second) view:
[self performSegueWithIdentifier:@"SecondViewController" sender:sender];
The segue style is push.
The second view has two top bar button, a back button which navigates back normally, and a custom right bar button, which do something on the background and after that navigates back with this code:
[self.navigationController popViewControllerAnimated:YES];
Sometimes, when I call this code, I want to call a function (like as a callback function) in first view, which refresh some stuff on the first view.
How can I do that?
I try to use in the first view the viewWillAppear, but I don't want to refresh stuff every time, just sometimes.
Thanks!
RESOLVED.
I found the way to solve the problem: When I use the prepareForSegue function, I can set the [segue destinationViewController] object's any property.
So I set a delegate property to the sender (fisrt) controller, and in the second controller, I can call [delegate anyFunction]
It is works, maybe it's a good solution... :-S
Delegation should solve your problem. Make the first view controller the delegate of the second and send it a message when you dismiss the view controller.