Search code examples
xcodeipaduisplitviewcontrollerdetailsview

Refresh iPad Master data from detail view


I'd like to be able to refresh the table on the master side of my app, based on an action taken in my detail view controller.

In this case, I have an orders table on the left (master) side that drills down to show 3 levels of orders: Open, Held & Sent. So, if I "change" the status of an order (put it on hold, take it off of hold, send it, etc.) I'd like to be able to reflect that on the master side. Any ideas?

From an action button in the detail view controller I've tried:

[[appDelegate.splitViewController.viewControllers objectAtIndex:0] reload];

and

OrdersRootController *orc = [[OrdersRootController alloc] initWithNibName:@"Orders" bundle:nil];
orc = [appDelegate.splitViewController.viewControllers objectAtIndex:0];
[orc.tableView reloadData];

I tried to add a notification but it's not working.

I'm adding an observer in awakeFromNib:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshOrders:) name:@"OrderStatusChanged" object:odc];

And posting from the order:

[[NSNotificationCenter defaultCenter] postNotificationName:@"OrderStatusChanged" object:self];`

But the selector specified never fires... What am I missing?


Solution

  • I would pass a reference (possibly in the AppDelegate) to the table view in the detail view to the master view, and directly call the table reload data.

    Or you can use notifications, the master view raises a notification and the detail view responds by loading the appropriate data.