I have three separated class, UIViewController (A) and two UITableViewControllers (B and C).
I add table B and C into A.
[A.view addSubview:B.tableView];
[A.view addSubview:C.tableView];
Now I need to change/reload one table by the selection in another table. For example, select “meat” in B then C become “chicken, pork…”, select “fruit” then get “apple, tomato…”.
My question is generally Howto get access to another controller/view. What should I write in didSelectRowAtIndexPath in B to access another controller (A, C)?
You are looking for delegation. Add a protocol to B and C and let the other implement it.
I wrote a sample code quite along time ago.
In there the CheckTableController can inform the ShowFavoritesTableController, as the second implements the delegate protocol of the first.