I am running through the "Navigating with tables" section of Wrox' Professional iPhone Programming with MonoTouch by McClure et al, picking up the basics of putting together a hierarchical UI for iOS, and running into the following problem.
I have created a new "iPhone View with Controller" file (called ParametersViewController), deleted the UIView from it, added a UITableView, created an outlet for it (tableView) and connected the "File's Owner" view outlet to the UITableView, per the tutorial.
In the RowSelected method of this view's parent view, I instantiate my ParametersViewController, calling the default constructor, in which I want to set up the table view's data source:
this.tableView.Source = new DataSource(this, new [] {"one", "two", "three"});
(DataSource is a nested class which inherits from UITableViewSource)
All compiles and runs fine, up until the point where that line is executed. Turns out that this.tableView is null, so I get a NullReferenceException.
tableView is the outlet for the table. How can it be null? Can't I set up the table source here in the constructor? If not, where do I do it?