UITableViewController numberOfSections is 0 by default


#1

I dont know if this is in the book or not but in the Kindle version there is no mention of setting the number of sections to be > 0.

Apparently, Apple now stubs out the required methods and some optional methods when subclassing certain classes , in this case, UITableViewController. Before, if i recall correctly you to had to type all of these out by hand.

In the stubbed out method:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { #warning Potentially incomplete method implementation. // Return the number of sections. return 0; }

you see that it is not returning any sections. If the data source is not returning sections > 0, then both required methods, numberofRowsInSection and cellForRowAtIndexPath are not called. Therefore your UITableView does not populate the cells with the BNRStore items. Changing the number sections to return 1 solves this issue. Even though(at least in the Kindle version) we say that we are only going to use 1 section so we only have to worry about the row, there is no mention of making sure the reader knows to change the number of sections to be returned to be 1.

Just wanted to make sure everyone knew this going forward or possibly any changes that might come to this book in the future. thanks!