views:

31

answers:

2

This is probably me being a little dim, I am setting up a UITableViewController via a UINavigationController, I have subclassed UITableViewController: (see below) and have implemented the datasource methods to get my table up and running

@interface RootViewController : UITableViewController {
    NSArray *dataList;
}
@property(nonatomic, retain) NSArray *dataList;
@end

My question is: when I came to implement the viewDidLoad for RootViewController I wanted to set the title for the table (See image below). I looked at the docs for UITableViewController and found that it had a property called "tableView" so I tried ...

[[self tableView] setTitle:@"Eeek!"];

This did not work, what I should have tried was ...

[self setTitle:@"Eeek!"];

What I am wondering, when you subclass UITableViewController and add code your actually dealing with the tableView and not the UITableViewController, does this make sense?

alt text

Gary

+1  A: 

what you are setting is actually the UIViewController (the parent class of UITableViewController) title, which is what UINavigationController uses to display a title in its navigationBar (the blue bar in your image)

Edit to better answer question: so no, when you subclass UITableViewController, you are actually dealing with the controller, not the table view itself.

Jesse Naugher
+1  A: 

Short answer to the question, no - you are still dealing with the properties of the Controller. The difference between the two setTitle: operations is:

// This message is being sent to the UITableViewController
[self setTitle:@"Eeek!"];

// This message is being sent to the UITableView property of the UITableViewController
[[self tableView] setTitle:@"Eeek!"];

There is no setTitle: method on the UITableView object, so that fails.

Abstractly in terms of MVC, the first is setting the property on a Controller and the second is setting the property on a View.

Eric