Is there a typo for subclassing NIB UITableViewCell?


I hit major stumbling with trying to move forward with the book’s project at the beginning of this chapter. I would appreciate any help possible.

I followed the directions explicitly (at least so I thought). I was trying to fix the layout and I hit something incorrectly and did a command-Z to undo my actions. Well, that appeared to completely flummox the view and my controls were no longer visible. I had to restart the creation of the NIB by blowing away the current NIB first. This is where my living hell began…

After creating it again, I found that I could not connect any of the subviews view the control-drag to the BNRItemCell.h file for the outlets. When I did that, it acted as if it didn’t recognize what I was trying to insert in the .h file. After several hours of aborted attempts at doing various things, I found that by subclassing the View (NOT the UIItemViewCell) allowed me to ctrl-drag and set up the outlets. And, it ran. I still have to work on the layout part.

The main question here is, is that a typo? If not, then why can I not subclass the UIItemViewCell as the book says to do? I’ve gone through all the obvious stuff (including redoing everything and rereading that section at least a dozen times) and no luck.

By the way, I did try to “force” the outlets, for one of my aborted attempts, to connect with the subviews when the UIItemViewCell was subclassed to BNRItemCell. When I ran the project, as soon as it tried to display a row, the app would blow-up complaining that about something where at least one UITableViewCell could not be found in the NIB file (I’m paraphrasing here). I lost a few hours trying to clear cache and restarting.


Nevermind. I found out what I was doing wrong. BUT, I think an errata should be issued to clarify something that a newbie like myself can find infuriatingly difficult to figure out. When adding a new UITableViewCell to the “canvas”, the authors should have noted to delete the default iPhone/iPad view that comes up and that UITableViewCell essentially goes onto the empty canvas as its own view. Yes, that might seem obvious to some (or most) and it seems obvious now to me. But, every other example showed controls/view items being dragged over into the iPhone view which is exactly what I did with this example and nothing was going right once I did that. Once I opened up the text’s solution that I downloaded, I realized my dumb mistake that I spent almost the entire day fighting.


I suspect that the authors deliberately leave a few things out / wrong. If deliberate it’s a good way to teach - rather than just copying from the book you have to work out why your code is failing. I believe that we learn by debugging.


@bgoldstein14: Many thanks for blazing this trail for us. I also got completely stuck on this and were it not for finding your question (and answer) I’m not sure I would have figured it out.

@vermoot: I agree that the authors (wisely, in my opinion) gradually decrease the amount of hand-holding as we progress up the learning curve. I appreciate this as it confirms to myself that I am indeed learning things. Indeed, on Page 371 they ask us to “Create an Empty XIB file…” without further directions. Fine, no problem. However, I don’t think it’s good practice (nor their intent) to supply wrong or incomplete information. If so, I’d not be a happy camper. My vote is that they should have instructed us to delete the iPhone/iPad view and then, as bgoldstein14 said, drag a UITableViewCell into the blank canvas. This instruction was missing, simple as that. That said, I agree with you of course that debugging is a very useful and instructional (if not also frustrating) learning activity.


Thanks for this. The chances of me stumbling on a solution on my own were vanishingly small. I did notice that the the look in the book didn’t match my screen, but I couldn’t figure out why. I’m all for asking more of the reader over time, but this isn’t something we covered to my knowledge so I’m not sure how I was supposed to know this.


I was having the same problem, but then I re-read the part about XIB file creation. I was creating a new “View” XIB file instead of the “Empty” XIB file as instructed in the book.

I think it was not author’s purpose to mislead, it was my problem of not reading it and following the instructions correctly.