Book Review: Core Animation for Mac OS X and the iPhone by Bill Dudney

What is Core Animation?


Core Animation is a powerful new Apple technology that debuted with Mac OS X Leopard. As it was later revealed, it was a technology that originated for the iPhone.


Core Animation is actually comprised of two different technologies:

1) An animation technology

2) A layering (compositing) technology


Core Animation makes it easy to animate a "view" object from point A to point B without having to write your own animation loop or timer callbacks. It can be as simple as just saying "move there" and Core Animation takes care of the rest.


The layering aspect is the part that caught my attention as an OpenGL developer. Basically, you can think of Core Animation as a textured rectangle engine, i.e. apply a 2D image on a quad, and then can transform it (translate, rotate, scale). Apple leverages OpenGL under the hood so this is all really fast...much faster than the traditional techniques which are CPU oriented instead of GPU oriented. But the real leverage of the technology comes from the fact that you can turn on Core Animation for any existing Apple widget so you can use their buttons and various views instead of reinventing the wheel making your own 2D image quads (not to mention event handling/responder chain).


Furthermore, because OpenGL is used as the back end for Core Animation, it is now finally possible to intermix previously unrelated UI pieces together in a single view. So for example, before it was really hard to superimpose an OpenGL view with a Quicktime view and a Cocoa view for building a sophisticated UI. The "layering" part of Core Animation is now the grand unification technology that allows all this to just work together because all can now be rendered via Core Animation layers which is all OpenGL at the bottom. (The technology was originally called LayerKit before Apple renamed it to Core Animation.)


I find this particularly compelling for building UI interfaces. Before I might do a lot of the hard painful work of writing 2D stuff in OpenGL directly that required fluid animation and speed. But now Core Animation provides a simple API to do this and already provides me powerful capabilities such as rendering high quality text (always a pain in OpenGL).


Unfortunately, documentation is hard to come by for Core Animation. I think it has hurt its adoption rate. 


Bill Dudney to the Rescue


Enter Bill Dudney who has addressed that shortcoming by writing the book "Core Animation or Mac OS X and the iPhone".


Bill Dudney covers it all, from simple animation and layer-backed views (i.e. using Core Animation with traditional NSView's on Mac) to using Core Animation layers directly for more powerful and expressive capabilities.


For anybody needing to deal directly with Core Animation, I think this book is a must-have.


However, I have seen some criticisms of the book, mostly from iPhone developers. So I want to be clear on what this book is about (or not about). 


This book is specifically geared towards Core Animation, not Cocoa or iPhone programming in general. (Dudney is working on a general iPhone book which is worth looking at.) And knowledge of just Core Animation is not sufficient to build an entire application. This book is best suited for those people who want to make superior and elegant UIs to differentiate their products (or simplify implementation in my case), and not settle for run-of-the-mill looking UIs. For example, he builds a simple Front Row like interface as one of his more advanced code examples. But also to be clear, as much as I wish we had such a thing, this is not an elite Cocoa tips & tricks book or gems book so the focus is learning Core Animation (via mostly simple isolated examples), not doing elaborate example projects.


There is a single chapter on iPhone at the end of the book. There are not a lot of differences between pure Core Animation on Leopard and iPhone, so iPhone doesn't really need a whole lot of discussion. However, this also underscores that the book was really written with a Mac centric focus. The first section of the book covers using Core Animation with NSViews which is an important topic on Mac, but irrelevant to iPhone developers. When the book moves into dealing with Core Animation layers directly, this information is directly applicable to iPhone developers. But I can understand that iPhone developers may experience frustration at needing to work with Mac examples in these sections rather than iPhone examples. But the examples are fairly simple and to the point so you generally don't need to focus on the infrastructure differences between Cocoa and Cocoa Touch. Still, if you are an iPhone only developer, you might want to hold off on this book purchase unless your need to understand Core Animation is great and you can live with the fact that a significant portion of this book does not apply to you.


One other criticism I've seen is that the photos in the printed book are not in color. I can say that the e-book version is at least in color, though I personally don't think color is all that important for the topic material. (You might argue motion is important for animation, but I don't know how to address that in book form, short of making a flip-book.)


I do hope he will do something to address the new features in Snow Leopard and newer versions of iPhone OS whether it be a blog entry or an update to a book.



You can buy the book here (link to Amazon):

Core Animation for Mac OS X and the iPhone: Creating Compelling Dynamic User Interfaces


Bill Dudney's website:

http://bill.dudney.net/roller/objc



Copyright © PlayControl Software, LLC / Eric Wing