views:

347

answers:

1

I want to reload the data within a table view that is contained on the root view of my application.

The root view of my application (called RootViewController) is a UIViewController that has a corresponding NIB file. I added a UITableView component to the RootViewController.xib via IB. In the header file RootViewController.h I ensure RootViewController conforms to . I have all this linked up correctly in IB and all the appropriate methods get called, viewWillAppear etc.

My question is, how can I get access to the UITableView so that I can call reloadData on it?

The following code won't work because 'self' is a UIViewController, not a UITableViewController.

[[self tableView] reloadData];

If I use the above code I get the following warning and my application crashes on startup:

'RootViewController' may not respond to '-tableView'
+2  A: 

You need to add an IBOutlet to your controller and link the that outlet to the tableview within Interface Builder. The NIB loading process will reconnect these outlets, giving your controller a reference to the table view.

Barry Wark
Thank you! Worked perfectly. Still trying to get my head around Objective-C/Cocoa.
redspike