I have the following config :
A ViewController parentController containing a TableView parentTable with customized cells to display 2 labels in each of them.
A ViewController childController containing a TableView childTable. This view is displayed when the user clicks a cell of controllerParent, and childTable content depends on the selected parentController cell.
I use this method :
[self.navigationController pushViewController:controleurEnfant animated:YES];
Now when I click a cell in childTable, I come back to my previous view with this :
[self.navigationController popViewControllerAnimated:YES];
Of course I can easily get the index of the childTable’s row selected. But the only thing I don’t know is how to keep this data to use it in parentController when I come back there ?
Thanks for your help…
For this kind of problem you can use delegation
Code from RayWenderlichs Tutorial:
.h in your childViewController:
.m in childViewController
in your parentViewController.h adopt the protocol
and implement the delegate methods
and don’t forget to set the delegate before pushing :
Here is some docu about the delegation pattern: Delegates and Data Sources