Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 763
Alan Carter Avatar asked Oct 29 '25 02:10

Alan Carter


1 Answers

Although you already chose an answer.. Call this anywhere in your DetailView:

UINavigationController *navController = self.splitViewController.viewControllers[0];
MasterViewController *controller = (MasterViewController *)navController.topViewController;
like image 146
Marc Avatar answered Oct 31 '25 13:10

Marc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!