How to reload data in parent UITableViewController from Modal ViewController

I have a navigation controller with a root view controller (UITableViewController). This table view controller has a modal segue to another navigation controller with the UITableViewController as the root view controller. From my modal table view controller I call

[self dismissModalViewControllerAnimated:YES]; 

to reject the view of the model. I try, before rejecting the modal view, to call my "update" function (which is in the first UITableViewController). I tried to use

 [self.parentViewController refresh]; 

but i guess i mean modal view navigation controller? For this reason, it does not seem to work.

+8
ios objective-c xcode
source share
1 answer

Create an NSNotificationCenter in your parent view:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:@"updateParent" object:nil]; 

Then call it when you reject the modal view:

 [[NSNotificationCenter defaultCenter] postNotificationName:@"updateParent" object:nil]; 
+13
source share

All Articles