Programming Mac OS X with Cocoa for beginners/What is Cocoa?
From Wikibooks, the open-content textbooks collection
Next Page: Installing the developer tools
Cocoa is possibly one of the most rewarding, fun and productive ways to program a modern computer yet devised. If you own a Mac running Mac OS X, you already have Cocoa, and all the tools needed to program your Mac using it. Anyone who has an interest in programming can use Cocoa to write Mac applications, yet it is not just for beginners; many of the best OS X software titles available are written using Cocoa. You are able to harness the full power of the machine from Cocoa.
Like Visual BASIC, programming using Cocoa involves both using a GUI tool to build your user interfaces, and a text editor to write the "back end", or working part, of the program. Cocoa consists of literally hundreds of ready-built classes, which are pre-programmed modules of reusable code, that you can simply include in your own work. Since these classes are well designed, powerful and fully debugged, using them saves you literally hundreds of hours in building in complex functionality.
Cocoa is the name given to the complete set of classes, grouped together into an Application Programming Interface, or API. It is not the only API on the Mac - the other main one is called Carbon, but this text will not be concerned with it.
Cocoa is programmed using an extended version of the C programming language called Objective C. Unlike C++, Objective C is a very small extension to the C language, but includes some features which are supremely powerful. In fact, in some respects for all the advanced features of C++, it still cannot match the elegant simplicity and power of Objective C. If you already know C, you will be right at home in Objective C within half an hour or so. If you know C++, most of the concepts will be familiar, but you may have to 'unlearn' a few things! This text assumes at least a passing familiarity with C.
To get the most out of this text, you will need to be running Mac OS X 10.3 or later. If you have 10.2, most of what is here will work OK, but the tools as described will be different, and a little harder to use. The coding examples avoid Cocoa features that only exist on 10.3 or 10.4, but later chapters will explain them.
Significant parts of this text describe older versions of Interface Builder. Some of what is described will not work with version 3.0.
Above all, this text aims to get you started in the smoothest way possible, so that you can begin to see not just how powerful Cocoa can be, but also how much fun it is to work with.