In a View I have this structure
vista1 UIView -> tabla1 UITableView -> tabla1_controller UITableViewController
vista2 UIView -> tabla2 UITableView -> tabla2_controller UITableViewController
I use views because depending of the orientation I move around the views.
Everything works fine, each tableviewcontroller gets data from sqlite and show the custom cells.
I want to add a behavior, when the user selects a cell in the second table, I want to change the content of the first table.
The first tableView gets information from a NSArray, how do I change
So how can I make this happen?
this is the second tableviewcontroller
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
/* I dunno how to reference the nsarray of the first table here */
first_table_array = ....
[tabla1 reloadData];
}
In this case is with two tableviewcontroller, but the real cuestion is,
How can I execute functions / change variables of another tableviewcontroller from one viewcontroller?
For example, in the tabla2_controller (UITableViewController) how can I execute [tabla1_controller reload] when the user clicks on a row of table2,
if both tables are in each own view and both views showed at the same time?
In tabla2_controller, create a variable like below
in .h file
in .m file
Then, when you create tabla2_controller, set tabla1_controller as value for this variable like below.
Now, in didSelectRowAtIndexPath of tabla2_controller, do the following.