Search code examples
objective-ciosuisplitviewcontrolleripad

iPad using multiple masterviewcontrollers in a Splitview


I'm currently working on an iPad split view application that uses CoreData.

Initially the MasterViewController has a selection of Cases presented to the user. When the user selects a Case the details of this Case are shown in the detail view. From hereon you can drill down other objects that are in a 1 to many link with the Case (i.e. Documents connected to the case) using a Tab bar embedded in the DetailView. This all works fine.

However once the user has selected a Case I want to use the screen real-estate from the Master view for new options using:

DisplayManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
PersonMasterViewController  *mvc = [[PersonMasterViewController alloc] init];
mvc.comingFromCase = managedObject;
[self.navigationController pushViewController:mvc animated:YES];

This all works fine and I get the new list of items of the other master view controller.

So here is my problem. How do I get the Detailview to respond to commands from the new master view controller? In the new Masterviewcontroller I tried stuff like:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    DisplayManagedObject *selectedObject = comingFromCase;
    [self.detailViewController.navigationController popToRootViewControllerAnimated:YES];
    self.detailViewController.detailItem = selectedObject; 
    [self.detailViewController.tableView reloadData];
}

But with no result. Could anyone point me in the right direction?


Solution

  • Never mind, I'm a complete idiot -_- Since I was calling the Case again from the new controller apparently the page doesn't get refreshed. So I would see no difference. Once I called one of the underlying objects it did show the right information.