Reputation: 625
I've got a Parse background block that uploads some data. This occurs in a view controller (lets call it addDataViewController
) that was pushed onto another view controller (where my table view is, lets call that tableViewController
). I need to reload that tableView when the data finishes uploading. Ive got a navigation controller embedded in my storyboard so ive tried doing
//In addDataViewController
//when the data finishes uploading
self.navigationController.viewControllers objectAtIndex:0];
but for some reason the viewController stack was nil
.
Then I tried referencing tableViewController
as a property of the addDataViewController
in prepare for segue of tableViewController
. I added a tableViewController
property to my h file of addDataViewController
//in prepare for segue of tableViewController
dataViewController.tableViewController = self;
then referenced that objects tableView
and called reloadData
, but nothing seemed to happen
[self.tableViewController.tableView reloadData];
I thought for sure that would have worked, but it didnt. Any ideas?
Upvotes: 0
Views: 501
Reputation: 114
If you are importing view controller then you must use [self.addChildViewController:tableViewController.view];
hope this will help.
Upvotes: 0
Reputation: 2716
one approach is to use notifications. in your addDataViewController you would fire a notification, when the update is done:
[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateDone" object:nil];
in your tableViewController you would subscribe to the notification in viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(doSomething)
name:@"UpdateDone"
object:nil];
and then:
-(void)doSomething {
[self.tableView reloadData];
}
Upvotes: 0