views:

37

answers:

1

Hello I have a view controller that loads from an xib i created. It has two toolbars and a table view in that.

I add this too the header file in the ViewController

@interface FilterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {

When I do

[self.tableView reloadData] 

It does throws up an error and does not build.

+2  A: 

Just making your UIViewController conform to UITableViewDataSource and UITableViewDelegate does not automatically give you a tableView reference.

You need to create a tableView IBOutlet and connect it in Interface Builder.

Also, why not just inherit UITableViewController instead of a UIViewController?

chrissr
Definitely check that the table view is wired up to an `IBOutlet` that is specified in the view controller's header file.
Alex Reynolds
yea i have it hooked up to an outlet called theTable, which i syncronise into the class. But that still does not work.
Matt
I am using a view controller so that i can display the toolbars properly.
Matt
If your `IBOutlet` to the `UITableView` is called `theTable`, then you should be calling `[self.theTable reloadData];`
chrissr
@Matt a `UITableViewController` is still a `UIViewController`, it has just implemented a lot of `UITableView` related things by default. There are few reasons to use a regular `UIViewController` over a `UITableViewController` when it's going to control a `UITableView` anyway.
Douwe Maan