O'Reilly logo

Learning Cocoa by Apple Computer Inc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preface

When you begin any enterprise, you must find a starting point. You set out from that starting point and acquire a basic vocabulary, a notion of boundaries and techniques, and a sense of how things fit together and what is possible. For those who want to learn how to create Cocoa applications, this book provides such a starting point.

This book eases your way into the experience of Cocoa programming. It encourages you to play, explore, and “kick the tires.” When you finish this book, you will be much better prepared to take on serious application development with Cocoa. Working through this book will not only make Apple’s development environment less mysterious, but also will make it an environment you’ll want to program in.

Extensive programming experience is not required to complete the examples in this book, though some experience with the C programming language is helpful. The code for each example is included in the text so you can simply type it in, and you can access the examples at the site listed in the URLs that follow. If you’re already familiar with an object-oriented programming language like Java or Smalltalk, you’ll quickly feel right at home with Objective-C, used throughout this book.

No prior experience programming on Mac OS X is necessary to complete the tutorials in this book. You may at some point want to explore the wealth of developer documentation that Apple includes with Mac OS X. In /Developer/Documentation, you’ll find detailed information on the Mac OS X system architecture, developer tools, release notes, and so on. Most Cocoa programming documentation is located in /Developer/Documentation/Cocoa, where you’ll find information about programming using the Objective-C language, along with Cocoa API reference documentation,including specifications of classes, protocols, functions, types, and constants. You can access this documention using Apple Help. Go to Developer Help Center, then choose Cocoa.

The programming examples in this book can be found on the Apple web site at:

And on the O’Reilly site at:


         http://www.oreilly.com/catalog/learncocoa
      

Although the aim is primarily to educate, this book is also intended—for those interested in programming—to be fun.

Organization of This Book

Learning Cocoa is structured in three parts.

Part I, Cocoa Overview

Cocoa Overview introduces the Cocoa frameworks and describes the high-level features they provide application programmers. It also includes a brief introduction to object-oriented programming, the Objective-C language, and the development tools used in Cocoa programming.

Chapter 1 explains the history of Cocoa, places it in the context of the Mac OS X programming environment, and introduces the frameworks and classes that make up the Cocoa API.

Chapter 2 makes clear the benefits of OOP practices as compared to procedural programming. It also provides an introduction to the terminology and core concepts that you must understand to effectively use the Cocoa frameworks that are introduced in Chapter 1.

Chapter 3 covers the basics of the Objective-C programming language.

Chapter 4 begins by introducing Project Builder and Interface Builder, the primary tools used in Cocoa development. It then goes on to describe the wide array of tools and utilities available to assist in building, debugging, and performance tuning applications on Mac OS X.

Part II, Single-Window Applications

Single-Window Applications begins with some simple tutorials to help you become familiar with the basic elements of Cocoa programming. It then proceeds to guide you through the creation of a series of increasingly complex example applications. The techniques and concepts you learn in one tutorial lay the foundation for the more advanced techniques and concepts in the next.

Chapter 5 is a short tutorial that shows you how to use the Mac OS X development environment to create a traditional Hello World application for Cocoa.

Chapter 6 uses a series of minitutorials to introduce the most fundamental design patterns used in constructing Cocoa applications.

Chapter 7 shows how to build a simple application from beginning to end, giving you an opportunity to experience the complete work flow typical of Cocoa application development. You’ll also learn to use a common object-oriented design paradigm called Model-View-Controller.

Chapter 8 focuses on events—both user and program generated—and how, as a programmer, you intercept, handle, and coordinate them in Cocoa.

Chapter 9 uses a simple tutorial application to introduce table views—user interface objects that display data as rows and columns. In the second part of the chapter, you’ll extend the application so that it can save its data to persistent storage.

Chapter 10 completes Part II of the book with a large tutorial that gives you an opportunity to combine all of the techniques that you have learned so far in a single application. Travel Advisor is a forms-based application used to maintain travel-related information associated with various countries to which the user travels.

Part III, Multiple-Window Applications

Multiple-Window Applications uses an extended tutorial (interwoven with key conceptual material) that shows you how to build a complex document-based application with Cocoa’s multiple-document architecture. You’ll design and code an application called To Do that allows you to go to specific dates on a calendar and enter a list of appointments or tasks for a particular day.

Chapter 11 describes Cocoa’s remarkable architecture that drastically simplifies the work developers must do to implement a multidocument application.

Chapter 12 walks you through the design and initial creation of the To Do application using Cocoa’s multiple-document architecture.

Chapter 13 takes you through the process of adding advanced features to the application you created in Chapter 12. You’ll add a Mac OS X Info window for setting various to-do item attributes such as alarms and due date rescheduling.

Chapter 14 wraps up the To Do application by adding some final polish. You’ll prepare the application for deployment by turning on compiler optimization, adding application and document icons, and configuring build settings to include things like version information and an application signature.

Appendix A provides an introduction to drawing using the Cocoa and Core Graphics (Quartz) APIs.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required