Wrapping the tableView in a custom view in UITableViewController

Ever wanted to add a different view north of your table view without making it the tableHeaderView?

Here’s what you need:

@property (nonatomic, retain) UITableView *internalTableView;

- (void)loadView;
{
    [super loadView];
    self.internalTableView = self.tableView;
    self.view = [[[UIView alloc] initWithFrame:self.view.frame] autorelease];
    [self.view addSubview:self.tableView];
    self.tableView.frame = self.view.bounds;
}

- (void)viewDidUnload;
{
    self.internalTableView = nil;
    [super viewDidUnload];
}

- (void)dealloc;
{
    internalTableView = nil;
    [super dealloc];
}

// here's the finesse
- (UITableView *)tableView;
{
    if (!self.internalTableView) {
        return [super tableView];
    }
    return self.internalTableView;
}