PDA

View Full Version : Reloading of TableView from another controller




sree
Jul 10, 2010, 10:34 AM
Hello,

This is a tab bar application created using XCode tab bar template.
After that I have added a nib called tableView.xib and pointed it to the first tab of the tabbar in the MainWindow.xib.
And in the tableView.xib I have added a tableView control.

These are the files I have.
tabbarAppDelegate.h
tabbarAppDelegate.n
FirstViewController.h
FirstViewController.m

MainWindow.xib
SecondView.xib
tableView.xib

Data source and delegate are pointing to the FirstViewController, and from its viewDidLoad method I am able to populate the TableView correctly.
(This controller has the mandatory TableView methods implemented)

What I need is to be able to do reloadData from the FirstViewController.

[tableView reloadData]; //does not work
[self.tableView reloadData]; //does not work

#import "tabbarAppDelegate.h"
tabbarAppDelegate*appDelegate = (tabbarAppDelegate*)[[UIApplication sharedApplication] delegate];
[appDelegate reloadData]; //too does not work

I have also tried to add the method viewWillAppear but that too does not detect the reloadData method.

I am new to this, please help me on how to access the tableView.

Thanks,
Sree



mathematician
Jul 11, 2010, 07:28 AM
Hello,

This is a tab bar application created using XCode tab bar template.
After that I have added a nib called tableView.xib and pointed it to the first tab of the tabbar in the MainWindow.xib.
And in the tableView.xib I have added a tableView control.

These are the files I have.
tabbarAppDelegate.h
tabbarAppDelegate.n
FirstViewController.h
FirstViewController.m

MainWindow.xib
SecondView.xib
tableView.xib

Data source and delegate are pointing to the FirstViewController, and from its viewDidLoad method I am able to populate the TableView correctly.
(This controller has the mandatory TableView methods implemented)

What I need is to be able to do reloadData from the FirstViewController.

[tableView reloadData]; //does not work
[self.tableView reloadData]; //does not work

#import "tabbarAppDelegate.h"
tabbarAppDelegate*appDelegate = (tabbarAppDelegate*)[[UIApplication sharedApplication] delegate];
[appDelegate reloadData]; //too does not work

I have also tried to add the method viewWillAppear but that too does not detect the reloadData method.

I am new to this, please help me on how to access the tableView.

Thanks,
Sree

[tableView reloadData];

should work. But maybe tableView is nil? Who is the files owner of tableView.xib and did you connect the table view in tableView.xib with the tableView outlet? If not, tableView will be nil and [tableView reloadData] does nothing.

Best
Christian

PhoneyDeveloper
Jul 11, 2010, 10:31 AM
Is FirstViewController a subclass of UITableViewController or UIViewController? Are you sure that tableView isn't nil? Is tableView an ivar/property of your view controller or of its base class?