With the advent of version 2 of the iPhone system, Apple proved they could do a remarkable
thing — adapt their existing Cocoa computer application programming
framework to make applications for a touch-based device with limited memory and
speed and a dauntingly tiny display. The resulting Cocoa Touch framework, in fact,
turned out to be in many ways better than the original Cocoa.
A programming framework has a kind of personality, an overall flavor that provides an
insight into the goals and mindset of those who created it. When I first encountered
Cocoa Touch, my assessment of its personality was: “Wow, the people who wrote this
are really clever!” On the one hand, the number of built-in interface widgets was severely
and deliberately limited; on the other hand, the power and flexibility of some of
those widgets, especially such things as UITableView, was greatly enhanced over their
Mac OS X counterparts. Even more important, Apple created a particularly brilliant
way (UIViewController) to help the programmer make entire blocks of interface come
and go and supplant one another in a controlled, hierarchical manner, thus allowing
that tiny iPhone display to unfold virtually into multiple interface worlds within a single
app without the user becoming lost or confused.
Even more impressive, Apple took the opportunity to recreate and rationalize Cocoa
from the ground up as Cocoa Touch. Cocoa itself is very old, having begun life as
NeXTStep before Mac OS X even existed. It has grown by accretion and with a certain
conservatism in order to maintain something like backward compatibility. With Cocoa
Touch, on the other hand, Apple had the opportunity to throw out the baby with the
bath water, and they seized this opportunity with both hands.
So, although Cocoa Touch is conceptually based on Mac OS X Cocoa, it is very clearly
not Mac OS X Cocoa, nor is it limited or defined by Mac OS X Cocoa. It’s an independent
creature, a leaner, meaner, smarter Cocoa. I could praise Cocoa Touch’s deliberate
use of systematization (and its healthy respect for Occam’s Razor) through
numerous examples. Where Mac OS X’s animation layers are glommed onto views as
a kind of afterthought, a Cocoa Touch view always has an animation layer counterpart.