| < Previous PageNext Page > |
It is possible to create a Cocoa application without adding a single line of code. Make a new Cocoa application project using Xcode and then build the project. That’s it. Of course, this application won’t do much, or at least much that’s interesting. But this extremely simple application still launches when double-clicked, displays its icon in the Dock, displays its main menu and window (entitled “Window”), hides itself on command, behaves nicely with other running applications, and quits on command. You can move, resize, minimize, and close the window. You can even print the emptiness contained by the window.
Imagine what you could do with a little code.
In terms of programming effort, Cocoa gives you, the developer, much that is free and much that is low-cost. Of course, to become a productive Cocoa developer means becoming familiar with new concepts, design patterns, programming interfaces, and development tools, and this effort is not negligible. But familiarity yields greater productivity. Programming becomes largely an exercise in assembling the programmatic components that Cocoa provides along with the custom objects and code that define your program’s particular logic, then fitting the whole assemblage together.
What follows is a short list of how Cocoa adds value to an application with only a little (and sometimes no) effort on your part:
Basic application framework—Cocoa provides the infrastructure for event-driven behavior and for application-, window-, and workspace-management. In most cases, you won’t have to handle events directly or send any drawing commands to a rendering library.
User-interface objects—Cocoa offers a rich collection of ready-made objects for your application’s user interface. Most of these objects are available on palettes of Interface Builder, a development application for creating user interfaces; you simply drag an object from a palette onto the surface of your interface, configure its attributes, and connect it to other objects. (And, of course, you can always instantiate, configure, and connect these objects programmatically.) Here is a sampling of Cocoa user-interface objects:.
windows | text fields | radio buttons | drawers |
sheets | tab views | table views | browsers |
pop-up lists | sliders | image views | color wells |
combo boxes | scroll views | text views | steppers |
In addition, Cocoa features technologies that support user interfaces, including those that promote accessibility, perform validation, and facilitate the connections between objects in the user interface and custom objects.
Drawing and imaging—Cocoa enables efficient drawing of custom views with a framework for locking graphical focus and marking views (or portions of views) as “dirty.” It includes programmatic tools for drawing Bezier paths, performing affine transforms, compositing images, and creating various representations of images.
System interaction—Cocoa gives your application ways to interact with (and use the services of) the file system, the workspace, and other applications.
Data exchange—Cocoa simplifies the exchange of data within an application and between applications using the copy-paste and drag-and-drop models and through the Services menu.
Performance—To enhance the performance of your application, Cocoa provides programmatic support for multithreading, idle-time processing, lazy loading of resources, memory management, and run-loop manipulation.
Document-based applications—Cocoa specifies an architecture for applications composed of a potentially unlimited number of documents, with each contained in its own window (a word processor, for example). Indeed, if you choose the “Document-based application” project type, many of the components of this sort of application are created for you.
Scripting—Through application scriptability information and a suite of supporting Cocoa classes, you can make your application scriptable; that is, it can respond to commands emitted by AppleScript scripts. Applications can also execute scripts or use individual Apple events to send commands to, and receive data from, other applications. As a result, every scriptable application can supply services to both users and other applications.
Internationalization—Cocoa uses an approach to internationalization and localization that has been refined over many years. This approach, based on users’ lists of preferred languages, puts localized resources in bundles of the application. It also provides tools and programmatic interfaces for generating and accessing localized strings. Moreover, text manipulation in Cocoa is based on Unicode by default, and is thus an asset for internationalization.
Undo management—You can register user actions that occur with an undo manager, and it will take care of undoing them (and redoing them) when users choose the appropriate menu items. The manager maintains undo and redo operations on separate stacks.
Text—Cocoa provides a sophisticated text system that allows you to do things with text ranging from the simple (for example, displaying a text view with editable text) to the more complex, such as control of kerning and ligatures, spell checking, and embedding images.
Printing—In a fashion similar to the text system, the printing architecture lets you print documents and other application content along a range of control and sophistication. At the simplest level, you can print the contents of any view by default. At a more complicated level, you can define the content and format of printed content, control how a print job is performed, and add an accessory view to the print panel.
Preferences—The user defaults system is based on a system-wide database in which you can store global and application-specific preferences.
Networking—Cocoa includes a Distributed Objects architecture that allows one Cocoa process to communicate with another process on the same computer or on a different one. It also offers programmatic interfaces for incorporating Bonjour capabilities in your application.
Multimedia—Cocoa provides support for QuickTime video and basic audio capabilities.
| < Previous PageNext Page > |
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-12-20)
|