[ Team LiB ] |
What Is Cocoa?Cocoa is a complete set of classes and application programming interfaces (APIs) for building Mac OS X applications and tools. With over 240 classes, Cocoa is divided into two essential frameworks: the Foundation framework and the Application Kit. The Foundation framework provides a fundamental set of tools for representing fundamental data types, accessing operating system services, threading, messaging, and more. The Application Kit provides the functionality to build graphical user interfaces (GUI) for Cocoa applications. It provides access to the standard Aqua interface components ranging from menus, buttons, and text fields—the building blocks of larger interfaces—to complete, prepackaged interfaces for print dialogs, file operation dialogs, and alert dialogs. The Application Kit also provides higher-level functionality to implement multiple document applications, text handling, and graphics. Classes are not the only constituents of the Cocoa frameworks. Some programming tasks, such as sounding a system beep, are best accomplished with a simple C function. Cocoa includes a number of functions for accomplishing tasks such as manipulating byte orders and drawing simple graphics. Additionally, Cocoa defines a number of custom data types and constants to provide a higher degree of abstraction to many method parameters. The Cocoa Development EnvironmentProject Builder and Interface Builder are the two most important applications used in Cocoa development. Project Builder is the interactive development environment (IDE) for Mac OS X used to manage and edit source files, libraries, frameworks, and resources. Additionally, it provides an interface to the Objective-C compiler, gcc, and the GNU debugger, gdb. Interface Builder is used to create GUIs for Cocoa applications by allowing developers to manipulate UI components (such as windows and buttons) graphically using drag and drop. It provides assistance for laying out components by providing visual cues that conform to Apple's Aqua Human Interface Guidelines. From an inspector panel, the behavior and appearance of these components can be tweaked in almost every way the component supports. Interface Builder provides an intuitive way to connect objects by letting the user drag wires between objects. This way, you set up the initial network of objects in the interface. In addition, you can interface without having to compile a single bit of code. Interface components are not the only objects that can be manipulated with Interface Builder. You can subclass any Cocoa class and create instances of the subclasses. More importantly, you can give these classes instance variables, known as outlets, and methods, called actions, and hook them up to user interface components. Interface Builder can then create source files for these subclasses, complete header files, and an implementation file including stubs for the action methods. There is much more to Interface Builder and Project Builder than we can cover in this book, but as you can begin to imagine, the tight integration of these two applications create a compelling application development environment. Cocoa Design PatternsCocoa uses many design patterns. Design patterns are descriptions of common object-oriented programming practices. Effective application development requires that you know how and where to use patterns in Cocoa. Cocoa in a Nutshell discusses these patterns in the context in which they are used. Here is a brief list of the design patterns you will encounter in the book:
BenefitsThese days, application developers expect a lot from their tools, and users expect a lot from any application they use. Any application or application toolkit that neglects these needs is destined for failure. Cocoa comes through grandly by providing the features needed in applications now and in the future, including:
Cocoa's most important benefit is that it lets you develop applications dramatically faster than with other application frameworks. LanguagesCocoa's native language is Objective-C. The Foundation and Application Kit frameworks are implemented in Objective-C, and using Objective-C provides access to all features of the frameworks. Chapter 1 covers Objective-C in depth. Objective-C is not, however, the only language through which you can access the Cocoa frameworks. Through the Java Bridge, Apple provides a way to access the Cocoa frameworks using the Java language. The Java Bridge does not provide a complete solution since many of Cocoa's advanced features, such as the distributed objects system, are not available with Java. This book will not discuss Cocoa application development with Java. Another option for working with Cocoa is AppleScript. AppleScript has traditionally been associated with simple scripting tasks, but with Mac OS X, Apple enabled AppleScript access to the Cocoa frameworks via AppleScript Studio. AppleScript Studio provides hooks into the Cocoa API so scripters can take their existing knowledge of AppleScript, write an application in Project Builder, and use Interface Builder to give their applications an Aqua interface—all without having to learn Objective-C. This exposes Cocoa to a completely new base of Macintosh developers, who know enough AppleScript to build simple task-driven applications for solving common problems. For more information about AppleScript Studio, see http://www.apple.com/applescript/studio. |
[ Team LiB ] |