Reloading of TableView from another controller

Discussion in 'iPhone/iPad Programming' started by sree, Jul 10, 2010.

  1. macrumors newbie

    Joined:
    Jul 10, 2010
    #1
    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
     
  2. macrumors member

    Joined:
    Oct 16, 2003
    #2
    [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
     
  3. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    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?
     

Share This Page