My Review of Matt Neuburg's book "Programming iOS 5" (O'Reilly Press)
iOS (iPhone OS) is Apple's unified operating system for its handheld/ mobile computing environments including the iPhone, iPad and the iPod touch. Matt Neuburg, the author of the O'Reilly "Programming iOS" series, has established himself as an expert in both the operating system and the large API set that supports it. His experience and authority shows throughout the book — this is clearly somebody who's spent decades in his field and has some real, useful, hands-on experience to share. I learned iOS programming from this book's predecessor, "Programming iOS 4". Just about the time I finished reading that book, it was already out of date with Apple's iOS 5 having rolled out. Now that I'm finished reading this 1000+ page book, it, too, is out of date as Apple has announced iOS 6. I look forward to a new edition of Neuburg's book which I will pick up as soon as it becomes available.
Structurally, "Programming iOS 5" is similar to "Programming iOS 4". Both books are split into seven parts, but they really break down into three logical ones. The first section covers the Objective-C language that you must use to interface meaningfully with iOS. The second section covers the XCode IDE that virtually everybody uses to develop iOS programs, and the third, longest section of the book covers the actual iOS API set (he breaks this third section into five "parts" for publication symmetry, but these last five sections are far more related to one another than the first two).
Part I - Language
The first section is almost identical in both editions of the book. It's not a bad introduction to Objective-C; it starts with a refresher on the core C language (Objective-C can be seen as a competitor to C++ — an object- oriented framework added to C). This chapter moves fast, so you'll probably want to have some prior exposure to C before picking up this book. The remaining four chapters of this section — one-tenth of the book — cover Objective-C. When I first picked up the first edition of this book, I had had no exposure whatsoever to the Objective-C language, but I was very comfortable with "regular" (procedural?) C. I found his coverage of Objective-C to be perfectly acceptable, albeit brief. I did have to refer back to these chapters a few times as I read later chapters to remind myself, for instance, what an Objective-C "Category" was, but the chapters are organized and indexed well enough that I could always find what I was looking for. From a learning perspective, it might have been nice if he had returned to some of the advanced concepts that a plain C programmer might not be familiar with when he talks about them from an iOS perspective, but it's not a terrible burden to go back and re-read the parts you didn't completely absorb when it comes back up.
I could summarize the differences between part I of the first and second editions in a few lines; Objective C itself didn't really change, so neither did the book. In fact, the only significant difference between the two books was coverage of ARC (Automatic Reference Counting), which is a new feature in iOS 5. Like I said, this whole section is comprehensive but brief; if you have time to invest in really learning Objective-C inside and out from another source before picking up this book, it will be time well spent. Still, I couldn't and didn't, and I don't think that my experience with the later chapters suffered as a result. The author has a tendency towards unnoted forward-references in this part, though — he'll say "delete the setNumber: method and its declaration", but how to do that isn't covered until a few chapters later. If you're an experienced programmer, you can probably figure it out, but it might be hard going with a lot of turning back a few pages to re-absorb something.
Part II - IDE
The section on the XCode IDE is only four chapters, but they're amazing chapters. His coverage of the IDE is nearly exhaustive — I now know what every single menu option and configuration screen in XCode is for. Although there are some obscurities he doesn't dig too deeply into, like the profiler, he shows you where they are and gives you a high-level overview of everything in there. This is where the author's experience shines — he knows all the ins and outs and tips and tricks of the code/interface builder integration. He even shows three different ways of connecting interface builder objects to code. (One surprising omission is that he doesn't talk, at all, about how to use gesture recognizers in the NIB editor. He doesn't talk about that in chapter 18, on gesture recognizers, either — so if you want to do this without code, you're sort of on your own).
This is a guide to using an IDE, though, so there are lots of screenshots in this part. There were a few places where the screenshots didn't match the screen, even though I was careful to ensure that I used the exact same version (4.3) that the author did. Still, these instances were few and far between, and in each case I was able to figure out how to do what the author was talking about anyway.
Part II ends out with a very good end-to-end look at Apple's appstore and the submissions process from start to finish. He talks about some decisions you can make early on (like providing a startup image) that will ease your pain when you get to appstore submission time — this is great advice, and not something you're likely to be thinking about when you set out to write your first iOS app.
Part III - CocoaCocoa is Apple's standardized UI framework. It grew from the NextStep/OpenStep programming environment that Steve Jobs headed up in between his times running Apple. Cocoa is actually not necessarily iOS specific, and you'll learn a handful of things in this section that are useful in the Mac OS/X programming environment. However, this book is specifically about iOS programming, so the four chapters that make up this section don't aim to be exhaustive — the author shows you the parts of Cocoa that are important to iOS. Specifically, what Apple refers to as Cocoa Touch; their adaptation of the Cocoa framework to a touch-and-gesture based environment. This section is where I most often found myself having to thumb back to part I to remind myself how, say, "key-value coding" worked.
This section also had probably the biggest departure from the first edition in chapter 12 on memory management — memory management changed completely between iOS 4 and iOS 5, so this chapter was rewritten in its entirety. He still does a good job of covering the "old" iOS 4 way, recognizing that there will be a lot of legacy programs out there for quite a while. However, outside of this chapter, all of the sample code assumes use of the new ARC memory management facility, so you'll probably want to pay very close attention to this chapter. Memory management is a big deal in iOS, and Neuburg does a great job of explaining exactly what your responsibilities are in that regard. The only thing that was sort of off-putting is that he keeps repeating the phrases "as it were" and "vanish in a puff of smoke" (the latter three times on a single page in one instance).
Part IV - Views
Part V - Interface
This is technically where the real iOS programming section starts. This part (and, really, the rest of the book) are iOS specific. This is about two-thirds of the book, and gets into some very specific detail. The discussion of, for example, layers and animation is a hundred times more accessible than any of Apple's own documentation on the subject. The author takes heavy advantage of the API here and always does things the "Apple way" rather than show you his own solutions to various problems. This is also where you see the second-biggest difference from the first edition of the book when he covers storyboards. I was happy to see that, rather than blindly drinking the Apple kool-aid, Neuburg accurately predicts that the storyboard functionality is most useful for beginners putting together toy apps, but will likely get in the way in any real-world scenario. Still, since all of Apple's demos draw heavily on storyboards and segues, you'll need to know how they work and how they relate back to other code — this book does a good job of describing them while not relying on them.
This is also where you can really tell that this is a book about the iOS programming environment, and not just a book about writing cool iPhone apps. The TableView, which is really the workhorse of real-world iPhone apps, isn't presented until chapter 21. A "get started quick" book would probably have presented the Table View towards the beginning, but this book takes the time to lay the groundwork for really understanding it before showing it to you. The coverage is excellent, though, and by the time you get there, everything is tied together so that table views make intuitive sense. His explanation of why a modal view controller will overlay an entire tabbed view controller in chapter 19, for example, is the sort of thing you'd never figure out in ages from reading Apple's documentation.
Parts IV & V — spanning twelve of the book's 40 chapters and almost half of its page count — are really the meat of the book; he attempts to cover every facet of the UI infrastructure. The chapters are logically placed so that there are few forward references and everything seems to "build on" what came before it. In terms of organization, I can't imagine there's a better way to present the iOS API. My biggest complaint, though, is that the organization of the book makes it very hard to follow along. When he presents the compass view in chapter 16, for example, he does present the code to draw it... but doesn't ever tell you that this code needs to be inserted into a custom "setup" method, called from "layoutSublayers". In chapter 20, he tells you how to make a view zoomable, but forgets to remind you to implement UIScrollViewDelegate. This is all stuff you can infer correctly if you've read (and completely absorbed) the previous chapters, but it makes the book a bit harder to read. It's never made clear if he's showing you something that you'll need to reuse later, or if he's just demonstrating a technique for your edification. If you want to see a fully-worked-out example, you'll have to download the code samples from the companion site. The downloaded code is indexed by page number - of the print edition. Unfortunately, this doesn't match up with the digital edition, so you'll have to go through a hunt to find the corresponding code samples if you have a non-print edition.
Part VI - Some Frameworks
Part VII - Final Topics
The remaining 13 chapters — about 250 pages worth — are sort of a "catch-all" for topics that didn't fit in earlier chapters. Again, most of this is essentially unchanged from the previous edition. I got the sense from the chapters on audio, video, photo & calendar that the author didn't have a lot of hands-on experience with these APIs and was mostly presenting the same detail you'd get from the online documentation. This isn't necessarily a bad thing, but if you wanted to, say, replace the built-in calendar app, you'll need to do some further reading after finishing this book. The chapter on the maps API is better than the others in part VI — I got the sense that the author was a lot more excited about this than the other topics. He also spends a lot of time on map samples in chapter 20 (Scroll Views).
The book is rounded out with some discussion on storage, networking, threads and undo. All of these chapters are introductory rather than comprehensive — I was honestly hoping for a more thorough treatment of networking, but this book is very UI-focused (and at 1,000+ pages, he understandably had to cut something short).
All in all, I think this is a great book. The author's introduction to this second edition includes a rant about some of the negative feedback he's gotten on the first edition — I agree that some of it isn't quite fair, since this book is very specifically geared towards making you, the reader, an expert on the iOS user interface APIs, with some lighter treatment of the peripheral topics. It's not a "learn iPhone programming in 21 days" book, and it's also not an Objective-C book. The only improvements I'd like to see in a future edition would be more cross-referencing of previous topics (e.g. when layers and key-value coding are presented in chapter 16, include a "see pg. 91 if you've forgotten how key-value coding works" link), and a better sense of how the code samples fit together. Still, if you've got some good professional programming experience and don't need a lot of hand-holding, this is a great book to learn iOS programming from.