As I understand this correctly form the Apple Api, when initializing a UITableViewController with the initWithStyle method, it should return me a reference to an UITableView in self.tableView. Which would make sense as you cannot change the style of a tableView once initialized.
But in my case this does not happen.
- (id)initWithSomeData:(SomeData *)someData {
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
}
NSLog(@"self? %@ tableView? %@", self, self.tableView);
return self;
}
This display's a object ID for self, but self.tableView is null. Am I doing something wrong? I'm not using interface builder!
Answer: Jan was actually right, I found out that the initialization process of a UITableViewController somewhat differs from a normal UIViewController.
My understanding was that at creation one of the init methods was called and would be completed before any other methods (loadView, viewDidLoad) we're called. This is correct for a UIViewController, but not for a UITableViewController.
The UITableViewController initWithStyle initializer actually calls loadView and viewDidLoad as part of it initialization process. The property of self.tableView is being set in loadView, but not if you override loadView, which I had done and hence, self.tableView was not being set.