TUAW Bookshelf: iPhone in Action

I've never found book reviews to be terribly helpful -- technical book reviews even less so, as how one learns differs from person to person. Some iPhone devs out there learned simply by poring over Apple's copious documentation. Others have been poking at the iPhone's innards since pre-SDK days, learning as they went from forums and good old hacking. But once the NDA lifted, the floodgates of iPhone dev books opened.

Each book and each publisher has a different angle both in content and presentation. Each book may appeal to different people and different learning styles with different backgrounds (not to mention the numerous sites, blogs and video resources out there beyond what Apple provides). Over the course of 2009 we'll be taking a look at some books in a new series called TUAW Bookshelf. We won't just be covering developer resources, either. There's a wide world of Apple-related reading out there, so stay tuned as we pull from our personal libraries and share our thoughts on what's available.

To kick things off I read iPhone in Action by Christopher Allen and Shannon Appelcline, published by Manning. I wound up reading this first because one of the authors threw a few copies at me while at Macworld (sorry, I don't know who you are and I can't seem to find your business card!). We've got a few to give away, but look for that in another post this month.

iPhone in Action
is designed to be a soup-to-nuts intro to almost everything you can develop for the iPhone. This includes web apps, which was the book's main focus until the SDK was announced while they were writing. I don't think shifting focus to the SDK is a bad thing, and as near as I can tell it didn't hurt the content. In fact, I thought this book would make an excellent primer to Apple's mobile platform efforts. Having taught technology for six years, I can say this is the book I'd use for a 100-level course in developing for the iPhone. I'm not saying it will make you into an expert overnight, and I'm not saying you can't come to the table with zero dev experience, but as a starting point, it is wonderful. To find out why, keep reading...

This book's method is to start from the beginning of Apple's foray into mobile: by tackling the web developer route first. If I were teaching a class on the basics of developing for Apple's new mobile platform, I would definitely use this as the textbook. I feel it does need a human guide, however, if you have only web dev experience.

I've broken down my review into the overall book's structure, the structure within each chapter, and what ancillary items are available to you when purchasing the book. As we go, I'll provide some commentary on the content.

Book Structure

From an instructional design standpoint, this book is marvelous. The authors (again, who had intended only a book about developing sites and web apps for iPhone) begin with optimizing a "regular" website for iPhone viewing. Well, in fact, they start by explaining the differences between developing web apps and SDK apps. This, plus info about the device, and honest talk about the differences in developing for either side of the house, is a good background for readers. Plus, it's terrific how it starts with web apps, even touching on Dashcode, and jumps into SDK, but brings the two together at the end. That is the masterstroke here. What began as a fluke of timing turned out to be a serendipitous win for readers. This sets the stage for later chapters, and if you're trying to decide if you'll like the authors' style, I would recommend reading the first couple of chapters (available free on Manning's site).

There are four parts to the book: the intro, designing web pages/apps, SDK fundamentals and SDK programming. I learned a lot in the first two parts, and was able to quickly tune a few web pages to work better with the iPhone. This is a nice setup for entrepreneurs, who should always consider iPhone visitors to their sites before they launch apps on the store.

But the book goes from web optimization, to custom jobs for iPhone, to true web apps, to Dashcode -- a move I applaud. With SDK madness, the web tools Apple has provided get short shrift. I understand that it isn't as easy to monetize web apps, but tech like Canvas and tools like Dashcode deserve a little respect, really. Plus, there are key concepts you should know about web dev work on iPhone before getting into the SDK. Don't forget that Apple rolled out the platform in this way, and it's a nice path to follow for new devs, in my opinion. Those first two sections provide a solid foundation for building fully-functional web apps (and a nice jumping off point for building Dashboard widgets, if anyone does that nowadays).

The last two parts are much more rigorous in their examination of programming and the SDK. You really do start from the beginning, with the very basics of object-oriented programming. Except, there's no way for a book this size to cover all the patterns and terms and knowledge necessary to start from zero. You will need previous experience, I think, and preferably in something that deals with objects. If you have experience with Ruby, for example, this will be a breeze. If you only have some limited JavaScript experience, you'll need to do a little outside homework.

With part 3, the authors run through basic programming, Objective-C, then Xcode and Interface Builder. All the while you're putting code into practice, building the traditional "Hello World" app, plus a couple of small apps. The idea is to lay the foundation for the next section, which really implements the features of the iPhone and Cocoa Touch.

Part 4 starts with building apps using preferences, storing data, and walks you all the way up to OpenGL and Quartz, but leaves with an in-depth discussion of web views and XML. In effect, this takes you all the way back to the beginning, with web apps, only this time the idea is that of a hybrid app: one that leverages the SDK and web tools. I think it's a brilliant way to circle back and illustrates why readers needed to grok the info in the first two parts.

Note that whenever a topic is too deep to cover (OpenGL, for example) the authors point out what it does, how it would be used and proceed to give a URL where you can learn more. They handle these diversions very well.

Chapter Structure

Chapters within each "part" of the book build upon each other. The last chapter of the web portion in the book is a bridge to the SDK portion, explaining stuff like C concepts to web developers. So there's a nice handoff from chapter to chapter, even when spanning new concepts.

Subsections in each chapter are denoted by the familiar #.#.# format. Chapter 9's subsection on memory management and pointers is labeled 9.1.2, for example. Code is in a traditional monospaced typeface, and many longer sections are labeled and explained within the text. There are several illustrations, but the book isn't in color. Most of the illustrations are great for illustrating either iPhone-contextual displays or hierarchical data (for understanding OOP concepts). In addition, tables are sprinkled liberally throughout the text. Most tables summarize info about the object being discussed. This is helpful, as you can quickly refer to a list of methods and what those do for any particular object.

Perhaps most important for a tech book: there are just enough examples for you to do in each chapter. I would like to have more, especially if I were teaching this as a course, but I think the authors balanced the content well. Also, examples start as explicit, step-by-step instructions, but rapidly move to a skeletal approach, giving you the info you need, but relying upon your previous learning to put it all together. This is why I suggest a human guide -- those leaps can be distressing for some.

As far as I could tell, the information in each chapter was up-to-date as a dead tree book could be, and the accuracy was great. Since the SDK is a moving target, you'll have the inevitable slips (like Celestial vs. the new kosher audio frameworks that don't require you to drop into C for audio playback). But that's what online resources are for!

That said, besides the text in the book, there are ample online resources to help readers out.

Additional resources

The first thing that caught my eye with this book was an insert providing special codes to download the PDF version of the book. The very first book I bought for the iPhone was Erica's iPhone Cookbook, and I bought it in PDF form precisely because it is easier to copy/paste code snippets. Unfortunately, the code annotation I pointed out earlier can cause issues with copy/pasting code from (Adobe Acrobat didn't have the same issues). In Preview, if you select the text, it will also grab the annotated text that relate to the book text below. You can easily strip this out, but it adds a step. Otherwise, the PDF version was great to have on hand. It's in color and is easy to search, as a good PDF book should be. The one improvement here might be some incremental updates, as things change. I realize that's a lot of work, however, so it's an understandable omission (plus, what would motivate you to buy the 2nd edition?).

The book's forums are great, but they don't replace the vast array of forums and newsgroups already out there for iPhone development. Since there are so many ways to code things, the forums do a great job of clarifying choices made by the authors. I found Appelcline was very active and patient in explaining those decisions.

The forum clears up aspects of the book that hit moving targets. and in iPhone dev land, there are plenty of moving targets. @class definitions, used a couple of times in the book, are now defined by @implementation and @interface. But that's the beauty of forums!

The book blog isn't mind-blowing or anything, but it does provide a backup for the bookmarks. The Manning site links to a collection of bookmarks hosted at ma.gnolia, which is currently shut down. The blog links to some of those bookmarks.

Naturally, the code samples from the book are available as Xcode projects for download. Everything I downloaded appeared to work great.

Final Thoughts

iPhone in Action is listed at $39.99 (the one I got says "includes ebook"). Is it worth it? Again, if I were building a course to teach people all about developing for this platform, this would be the book I'd use to structure the course. The logical progression then takes you through tuned web pages, to other frameworks (like iUI) to Dashcode, and even stops for a moment with Canvas. All of this is not only prep for the later SDK stuff, it's good info on its own. I would still like to have seen these guys finish their web book. I get the feeling there was more to tell, but the SDK sells more copies.

The SDK portion doesn't get short shrift, but I would say it might not give you everything you need. It will, however, point you to additional resources that will help. Particularly if you don't have OOP experience, you're going to want to step back and go through more rudimentary training. The SDK portion is ambitious, however. Attempting to scale such a tall mountain in such a short span of time is tricky. I think the authors did an admirable job, starting with C concepts, OO concepts, then building with views, controllers, Xcode, Interface Builder, all the way up to accessing GPS and accelerometer data, plus touching on larger topics like MySQL and OpenGL.

If you really are looking at the iPhone for the first time, but you have some programming experience, I'd say this book will get you up to speed. If you have no programming experience (or limited scripting experience), I would suggest you start with something like Kochan's book or the Cultured Code screencasts first. iPhone in Action is a complete primer to iPhone development, but you'll need to come to it with some basic coding skills.