Errata?


#1

Enjoying the book enormously - particularly the delegate and MVC diagrams which have clarified several things for me. I have a lot of bits of paper with less clear scribblings on them from following other books!
On p 147 you suggest that the TableView methods are already in the ItemsViewController, but in fact they aren’t as on p. 140 you tell us not to to make the ViewController a TableViewController in the new File dialog.


#2

Thank you for mentioning this, I’ve yet to fix it.

Back story for anyone confused or interested:
About 2 weeks before we sent the book off to the printer, Apple shipped yet another version of Xcode with a new set of templates. At this point in time, the book would instruct the reader to create UITableViewController subclasses by choosing the UITableViewController subclass template in the New File… menu.

However, the new UITableViewController subclass template had a subtle change: the UITableViewDataSource methods that needed to return data (number of sections, rows, cells) had code-completion placeholders in their implementation.

This was a serious problem for anyone new to programming using our book: occasionally, we will tell you to implement a few blocks of code and build and run the application to make sure that not only is your code typo-less, but so that you can see the effect of each line of code and that you truly learn what you are doing by using those lines of code. This is true of the chapters in which a UITableViewController subclass is created. The problem is that we spend some time setting up things in code and asking you to build and run before you ever edit the UITableViewDataSource methods that have code placeholders. Therefore, the compiler will generate an error because these placeholders have not been replaced with real code.

To make matters worse, the error generated by placeholders left in code is extremely misleading. The compiler will complain about the unrecognized characters, < and #. Of course, the Xcode user will not be able to see any <# characters because these are interpreted by Xcode as code completion placeholders. That means when Xcode sees: <#(NSString *)foo#>, you see a code completion placeholder that reads (NSString *)foo. (How do you find this out? Start typing a method that takes arguments, tab to the argument, perform a cut on the placeholder, and then paste it into TextEdit. Cool, huh?)

So, in order to focus your learning, we chose not to use the UITableViewController template until later in the book (Core Data), where there is a discussion about why you had not been using it beforehand. Unfortunately, I did not catch the note later in this chapter that assumed the use of that template. Apologies for the confusion.

On a related note, it is my hope that Apple takes code completion place holders out of the template. I am shocked that they did so in the first place; by putting these placeholders in, it prevents a programmer from building or running before they fill out these placeholders. The number of rows, sections and cells to be returned from a UITableViewController are not the first thing you implement in a table view controller subclass. They come much later in the game, after you have set up your model objects that the UITableView will be presenting. In practice, I no longer use the UITableViewController template for this reason alone.


#3

Thanks Joe - that’s excellent advice. And a great explanation! I had no idea about the code completion placeholders - too much reliance on magic!
It is a bit annoying that Apple’s shells for tableViews don’t work out of the box and it does kind of eliminate some of the “ease of use” that is elsewhere in their templates.
Now, back to wrestling with why the titles “expensive stuff” and “cheap stuff” (the keys of a dictionary) aren’t showing up in the challenge as section headers. In fact, -(NSString *)tableView: titleForHeaderInSection:section isn’t even being called…
Cheers
Peter


#4

A typo. It’s great when it all works.


#5

[quote=“pneame”]Enjoying the book enormously - particularly the delegate and MVC diagrams which have clarified several things for me. I have a lot of bits of paper with less clear scribblings on them from following other books!
On p 147 you suggest that the TableView methods are already in the ItemsViewController, but in fact they aren’t as on p. 140 you tell us not to to make the ViewController a TableViewController in the new File dialog.[/quote]

It’s listed on pg 136 (5th paragraph down) in mine (PDF version from Safari) as well…

“In ItemsViewController.m, you can see that the required methods have already been implemented by the template. Delete the implementation for them because you’re going to write your own…” But on pg 131 right after “Subclassing UITableViewController”, the books states, “While there is a checkbox of a UITableVIew Controller, do not check this. (The Xcode template for a UITableViewController subclass fills in too much code.)”

It’s probably exactly the same thing, but I figured I would just call it out anyway