So I’ve been working thru the book, and I’m up to chapter 28, working on the Nerdfeed app. Everything was working almost as expected, except for one small detail. When I clicked on an entry to view the post the first time, nothing happened. When I clicked on a second entry, it showed me the post for the first entry. Each click showed me the post for the previous click instead of the current one.
At first I suspected an off-by-one error, but I checked thru the code and didn’t see where that could be happening, and further testing by clicking random entries showed that I really was seeing the post for the previously-clicked entry and not for (row - 1). So I downloaded the completed code for chapter 28 and compared it to mine, and it appeared identical.
After a couple of days away from it, I started looking at the project again. The problem had to be in ListViewController.m, since that’s where the click/tap is handled. This time, after only a couple of minutes, it hit me. Instead of tableView:didSelectRowAtIndexPath:, I had tableView:DidDeselectRowAtIndexPath:. The code was doing exactly what I told it to do – showing me the post for the cell that I had just left.
Lesson learned: Be careful with auto-completion!