iTunes_RGB_9mm

Cool Mac Gear


iPod Video
iPod nano
iPod 1G-2G
iPod 3G
iPod 4G
iPod Mini
PowerBook-iBook
Garageband

Moore's Views & Reviews

Charles Moore Checks Out “ Building Cocoa Applications: A Step-by-Step Guide”

Friday, June 28, 2002


By Applelinks Contributing Editor Charles W. Moore

I’m not calling this article about Simson Garfinkel & Michael K. Mahoney’s new book, Building Cocoa Applications, a review, because for someone is ignorant as I am about computer programming to presume to critically evaluate a programming manual would be an act of hubris.

However, the publisher, O; Reilly, kindly send me a review copy, and having dug into it a bit, I’m inclined to believe that had I the time and the inclination, this book could teach even me, a complete neophyte, how to create a Cocoa program, although its intended audience is serious developers making the transition to writing Objective-C programs for OS X, and it assumes some facility with programming in general and the ANSI C language in particular.

This is the book covers a wide range of related technology for:

• The Aqua graphical user interface, Cocoa developer tools, object-oriented concepts, in the Objective-C language

• Cocoa programming and graphics concepts: nibs, icons, delegation, resizing, events, responders, tasks, pipes, color, Rich Text, the mouse, zoom buttons, pasteboard, modal sessions, and drag-and-drop

• The Cocoa environment: Darwin and the Window server, the document based architecture, the Quartz drying system, Cocoa’s preferences and default systems, and facilities for saving, loading, and printing.

Cocoa is an object-oriented development environment heavily grounded in the NeXTSTEP/OpenSTEP OS that is purely a Mac OS X native, as opposed to the Carbon API that converts Classic Mac OS programs to run natively in OS X.

Building Cocoa Applications walks the reader through building three functional Cocoa applications:

Calculator (Part II)
A simple, 4-function calculation application that similar to the calculator that comes with Mac OS X

MathPaper (Part III)
An application that is similar to a word processor but that solve equations you apply supply

GraphPaper (Part IV)
A more complex, multitreading application that graphs a formula into dimensions

The authors affirm that programmers with only a few months exposure report that they can develop a Cocoa application 3 to 10 times faster than they would could using other development environments such as Microsoft Foundation Classes

Building Cocoa Applications is divided into four parts:

Part I, Cocoa Overview, discusses the Mac OS X Aqua interface, Cocoa developer tools, the Objective-C language Cocoa is written in, and Cocoa programming itself.

Part II focuses on building the first complete application, Calculator. The chapters in this part of the book extend the application, piece by piece, by introducing such features as nibs, icons, delegation, resizing, events, and responders.

Part III focuses on building\ MathPaper. The chapters in this part of the book extend MathPaper by developing both the front and back ends using a variety of Cocoa classes and methods. They introduce Cocoa’s document-based architecture, tasks, pipes, Rich Text format, handling document files, and using Quartz to draw in windows.

Part IV focuses on building the GraphPaper application, a more complex multithreading application that graphs mathematical functions in multiple dimensions and that uses mouse-over capabilities to identify graph points. The chapters in this part of the book add more advanced Mac OS X features such as multithreading, color, mouse events, zoom buttons, pasteboards, services, preferences, and the defaults database.

By the end of the book, readers who have built the applications as they have read will have a solid understanding of what it really means to develop complete and incrementally more complex Cocoa applications.

The first chapter of each of Parts II, III, and IV these three parts introduces the application and builds its most basic functionality. Each subsequent chapter adds a new layer of functionality.

To utilize the technologies and techniques described in the book, you will need a Mac computer running 0S X 10.1 or later, and a copy of Mac OS X Developer Tools, which is conveniently included free with Mac OS X.

Chapter 1, Understanding The Aqua Interface, is actually one of the best, concise descriptions of Aqua and how to use it that I have read anywhere.

The book is liberally illustrated with OS X screen shots, which look great even in black and white, and there are also numerous graphs and code samples. The application building projects are presented in a progressive, step-by-step structure, is the book’s subtitle indicates, and as noted above, I didn’t find the approach intimidating even as a programming ignoramus.

However, that’s pretty much all the comment I can offer regarding the book’s content. I am simply not competent to say more.

There is a comprehensive Table Of Contents, which I have included here in the Appendix, and a 15 page index.

Here are some comments from the authors and publisher:

“Cocoa embodies the principles of object-oriented programming from its user interface down to its very core,” says Simson Garfinkel, co-author of “Building Cocoa Applications.” “While it greatly simplifies the task of building applications for Mac OS X, the Cocoa environment is also different from the environments to which most programmers are accustomed. As a result, the learning curve can be pretty steep if you don’t have competent instruction.”

“Building Cocoa Applications” is a hands-on tutorial that teaches through example - not only simple and self-contained examples of individual Cocoa features, but extended examples of complete applications with enough elegance and complexity that programmers can put them to immediate use in their own environments.

“Since its release in 2001, Mac OS X has generated tremendous momentum as a development platform,” says Michael K. Mahoney, co-author of “Building Cocoa Applications.” “The combination of its Unix-based foundation plus the Cocoa, Objective-C, and Java programming environments makes Mac OS X the best and most comprehensive development platform available, by far.”

“Cocoa is built on top of the Objective-C programming language-- a language that’s simultaneously simpler than C++ and yet better suited to creating graphical user interfaces,” explains Garfinkel. “Whereas most people find programming in C++ a chore, most Objective-C programmers find the language to be a joy.”

The book includes extensive source code, available for download from the O’Reilly web site, along with an appendix listing additional resources.

Building Cocoa Applications: A Step-by-Step Guide
By Simson Garfinkel & Michael K. Mahoney
May 2002
0-596-00235-1, 648 pages, $44.95 (US) $69.95 (CAN)
order@oreilly.com
1-707-827-7000; 1-800-998-9938

For more information, visit:
http://oreilly.com/catalog/buildcocoa/

***

Appendix

Table of Contents

Preface

Part I. Cocoa Overview

1. Understanding the Aqua Interface

What Makes Mac OS X So Special?

A Quick Look at the Mac OS X User Interface

Basic Principles of the Aqua Interface

The Mouse and Cursor

Window Types and Behavior

Menus and the Menu Bar

The Dock

Controls

The Finder

Configuring Your Desktop, Step by Step

Menu Guidelines and Keyboard Equivalents

Working with the Filesystem, Step by Step

Summary

Exercises

References

2. Tools for Developing Cocoa Applications

Developer Tools

Utilities

Working with the Terminal

Debugging Programs with gdb

User Interface Design

Summary

Exercises

3. Creating a Simple Application with Interface Builder

Getting Started with Interface Builder

Adding Objects to Your Application

Objects, Messages, and Targets

Summary

Exercise

4. An Objective-C Application Without Interface Builder

The Tiny.m Program

An Introduction to Objective-C

Tiny.m Revisited

Summary

Exercises

References

Part II. Calculator: Building a Simple Application

5. Building a Project: A Four-Function Calculator

Getting Started: Building the Calculator Project

Building the Calculator’s User Interface

Building the Calculator’s Controller Class

Customizing Buttons and Making Connections

Compiling and Running a Program

Compiler Error Messages

The enterDigit: Action Method

Adding the Four Calculator Functions

Adding the Unary Minus Function to the Controller Class

The Files in a Project

Summary

Exercises

6. Nibs and Icons

Customizing MainMenu.nib

Managing Multiple Nibs

Adding Icons to Applications

Changing Calculator’s Application Icon

Cocoa’s NSImage Class

Summary

Exercises

References

7. Delegation and Resizing

Handling Different Bases

Delegation

Disabling Buttons for BetterMultiradix Input

Resizing Windows Programmatically

Two Very Important Classes: NSWindow and NSView

Summary

Exercises

8. Events and Responders

Events and the NSResponder Chain

Events and the NSApplication Object

The Event Loop

Catching Keyboard Events for Our Calculator

Summary

Exercises

References

9. Darwin and the Window Server

Unix, Mach, and the Mac OS X Environment

The Window Server and Quartz

Seeing All the Processes

Summary

Exercises

References

Part III. MathPaper: A Multiple-Document, Multiprocess Application

10. MathPaper and Cocoa’s Document-Based Architecture

The MathPaper Application

The Evaluator Back End

Cocoa’s Document-Based Architecture

Building MathPaper’s Front End

Summary

Exercises

References

11. Tasks, Pipes, and NSTextView

Processes, Pipes, and Resources

Making Evaluator a MathPaper Auxiliary Executable

MathDocument Class Modifications

Creating PaperController, a Subclass of NSWindowController

The NSScrollView and NSTextView Classes

PaperController Class Modifications

Summary

Exercises

12. Rich Text Format and NSText

Rich Text Format

Creating an RTF Class

Integrating Our RTF Class into MathPaper

Summary

Exercises

13. Saving, Loading, and Printing

Data Management with NSDocument

Saving to a File

Loading from a File

Marking a Document Window as Edited

Adding Printing Capability

Summary

Exercises

14. Drawing with Quartz

Animation in an About Panel

The Quartz Window Server

Implementing the About Panel in MathPaper

Quartz Graphics Data Types

Timers

Putting It All Together

Summary

Exercises

References

15. Drawing in a Rectangle: More Fun with Cocoa Views

The Advantages of NSView’s drawRect: Method

BlackView: An NSView That Paints Itself Black

A Closer Look at the NSView Class

BarView: An NSView with a Scaled Coordinate System

PolygonView: A Non-Opaque NSView

Responding to Events in an NSView

Autosizing Multiple Views in a Window

Summary

Exercises

Part IV. GraphPaper: A Multithreaded, Mouse-Tracking Application

16. GraphPaper: A Multithreaded Application with a Display List

GraphPaper’s Design

Working with Multiple Threads

Building the GraphPaper Application

Extending the Display List

Summary

Exercises

References

17. Color

Colors and Color Objects

Adding Color to GraphPaper

Summary

Exercises

18. Tracking the Mouse

Tracking the Mouse

Adding Mouse Tracking to GraphPaper

Summary

Exercises

References

19. Zooming and Saving Graphics Files

Adding a Zoom Button to GraphPaper

Saving to PDF

Saving to TIFF

Creating an Accessory NSView

Summary

Exercises

20. Pasteboards, Services, Modal Sessions, and Drag-and-Drop

Cut, Copy, and Paste with the Pasteboard

Using the Pasteboard in GraphPaper

Services

Creating Your Own Service

Drag-and-Drop

Summary

Exercises

21. Preferences and Defaults

Preferences and the Defaults Database System

Adding Defaults to GraphPaper

Making the Preferences Panel Work with Defaults

Setting Up a Multi-View Panel

Summary

Exercises

Appendix:. Cocoa Resources

Index


Charles W. Moore

Email This Article - Comment On This Article

Recent News
Page: 1 - 2 - 3 - 4 - 5

.

Reader Specials

Server Racks Online:
Apple Xserve CompatibleServer Racks and Universal Network Racks
42U KVM Switch Solutions:
High-End Mac and Multi-Platform KVM Matrix switching solutions!
Digital Camera Online:
Great prices on Digital Cameras and accessories!
KVM Switches Online:
Great prices on Mac KVM Switches from the leading manufacturers!
LCD Monitors Online:
Great prices on LCD Monitors from the leading manufacturers!
LCD Projectors Online:
Shop online for LCD Projectors from the leading manufacturers!
USB 2.0 Online:
Great prices on USB 2.0 products from the leading manufacturers

Serious Business Software:
Accounting, Sales, Inventory, CRM, Shipping, Payroll & more!

KVM Switch solutions for MACs:
DAXTEN is a KVM switch, KVM extender and monitor splitter specialist for PC, SUN and MAC applications from name brand manufacturers - offices worldwide.

The "Think Different Store: The iPod Accessories Store - iPod cases, iPod mini, iPod photo, speakers, itrip, inMotion, Soundstage and all other iPod accessories

Earn Cash with the ThinkDifferent Store Affiliates Program

Need A Web Site?
Applelinks Web Hosting Starting at 19.95 a Month

iTunes_RGB_9mm

iTunes_RGB_9mm

Cool Mac Gear


iPod 1G-2G
iPod 3G
iPod 4G
iPod Mini
PowerBook-iBook
Keyboard Skins
Garageband