Chapter 8. Using the Cocoa Frameworks

People use the word "Cocoa" in different ways to describe different things. For example, Cocoa can refer to the Objective-C programming language and dynamic runtime. In Chapter 7, you learned how to write simple programs in Objective-C. Some of that material, such as memory management, is specific to Cocoa.

Cocoa also applies to the Objective-C frameworks and libraries commonly used by Cocoa applications. Two principal frameworks among these include AppKit and Foundation. A few other smaller frameworks seem to be a part of the Cocoa family in one way or another, including the PreferencePanes and WebKit frameworks.

The Foundation framework contains Objective-C objects, protocols, and functions that are useful to Mac OS X programs in general, regardless of whether they are meant to be user-friendly applications or low-level system utilities. For example, things like collection classes, file I/O, and memory utilities are defined in Foundation. Also, some functionality commonly thought of as high-level application functionality lives in Foundation because it doesn't involve any user interface. Management of undo and user preferences are all part of Foundation.

The AppKit framework builds upon Foundation to implement classes essential for high-level applications, often limiting itself to graphic elements displayed on the screen. For example, windows, buttons, and menus are all AppKit features. Also, some specialized objects live in AppKit, even ...

Get Beginning Mac OS® X Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.