Learning Cocoa

( 2 )

Overview

Cocoa™ is one of the principal application environments for Mac® OS X. Among Cocoa's many attributes, its advanced object-oriented APIs allow you to develop in both Java and Objective-C. This revolutionary new way of developing sophisticated applications for the Macintosh is both powerful and easy.

With Learning Cocoa you'll become familiar with Cocoa application development, using Objective C, not merely by reading, but by doing. The book begins with a discussion of essential ...

See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (37) from $1.99   
  • New (7) from $1.99   
  • Used (30) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$1.99
Seller since 2007

Feedback rating:

(1325)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
0596001606 Fast Reliable Shipping From a trusted online seller!

Ships from: Cypress, TX

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$2.66
Seller since 2012

Feedback rating:

(21)

Condition: New
New SAVE $$$-DISCOUNTED SHIPPING ON ORDERS OF 2 OR MORE BOOKS! New old stock. (Bought out book store. ) Cover may show shelf wear. Fast and careful shipping!

Ships from: Round Rock, TX

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$6.96
Seller since 2008

Feedback rating:

(169)

Condition: New
0596001606 BRAND NEW NEVER USED IN STOCK 125,000+ HAPPY CUSTOMERS SHIP EVERY DAY WITH FREE TRACKING NUMBER

Ships from: fallbrook, CA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$19.24
Seller since 2009

Feedback rating:

(847)

Condition: New
0596001606 *BRAND NEW* Ships Same Day or Next!

Ships from: Springfield, VA

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
$45.00
Seller since 2014

Feedback rating:

(136)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$45.00
Seller since 2014

Feedback rating:

(136)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$62.91
Seller since 2005

Feedback rating:

(803)

Condition: New
2001 Paperback New Tracking provided on most orders.

Ships from: Grand Rapids, MI

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Close
Sort by
Sending request ...

Overview

Cocoa™ is one of the principal application environments for Mac® OS X. Among Cocoa's many attributes, its advanced object-oriented APIs allow you to develop in both Java and Objective-C. This revolutionary new way of developing sophisticated applications for the Macintosh is both powerful and easy.

With Learning Cocoa you'll become familiar with Cocoa application development, using Objective C, not merely by reading, but by doing. The book begins with a discussion of essential object-oriented programming concepts for those with no previous experience. It proceeds through an introduction to the Cocoa environment, development, tools, and some simple tutorials to help you become familiar with the basic elements of Cocoa programming. The remaining tutorials guide you as you create 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.

You don't need extensive programming experience to complete the examples in this book, though it would be helpful to have some experience with the C programming language. The code for each example is included in the text so you can simply type it in. 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, the language used throughout this book.

As you ease your way into the experience of Cocoa programming, you're encouraged to play, to explore, to "kick the tires." You'll finish this book much better prepared to take on serious application development with Cocoa, and you'll find Apple's development environment not only less mysterious, but one that you'll be eager to program in.

Written by insiders at Apple Computer, the book brings you information that you can't get anywhere else—and a potential leg up in the Mac OS X application development market.

Read More Show Less

Editorial Reviews

Library Journal
New Macintosh computers are already shipping with the updated Mac operating system, OS X. At its core are a pair of foundation libraries, Carbon and Cocoa, that ease and speed the development of new Mac applications. Apple staff wrote both books, which is good and bad. On one hand, readers know that the information is coming straight from the source, but too often publisher-penned books lack objectivity. Learning Cocoa introduces OS X's new programming aspects, e.g., Aqua, the "liquid" interface, through a series of basic programming projects. Learning Carbon provides much of the same type of information for the application program interface, also at a basic level. If your library serves a large number of Mac and student programmers, these are good tutorials to have on the shelf. But many members of those audiences have probably accessed the same information for free at developer.apple.com/macosx. Copyright 2001 Cahners Business Information.
Read More Show Less

Product Details

  • ISBN-13: 9780596001605
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 5/8/2001
  • Edition description: 1ST
  • Pages: 384
  • Product dimensions: 7.02 (w) x 9.20 (h) x 0.80 (d)

Meet the Author

This book was contributed to by the technical writers, engineers, support specialists, and other professionals at Apple Computer, Inc., who are committed to making Mac OS X a superior platform for innovation, productivity, and enjoyment. These professionals have diligently collected, compiled, and edited the information in this books to ensure that it is a useful resource for Mac OS X developers.

Read More Show Less

Read an Excerpt

Chapter 6: Essential Cocoa Paradigms

Contents:
  • Cocoa's Collection Classes
  • Create Graphical User Interfacesin Cocoa
  • Controls, Cells, and Formatters
  • Target/Action
  • Object Ownership, Retention,and Disposal

In this chapter you will explore a handful of programming topics that represent the fundamental building blocks of a Cocoa application. First, you'll learn how to use Cocoa's collection classes, a set of objects whose purpose is to hold other objects. Next, you'll explore the basics of building graphical user interfaces in Cocoa. You'll learn to use Interface Builder and discover how this powerful tool interacts with Project Builder and the Cocoa frameworks to allow you to very quickly prototype and build applications. Last, you'll delve into the intricacies of object ownership and disposal in Cocoa, ensuring that your applications use resources efficiently.

These topics have been singled out for special attention because they are central to the design of the Cocoa frameworks, and the architectural perspectives involved are likely to be unfamiliar to developers new to the subtleties of object-oriented programming. Exploring these design patterns will help steep you in the mindset of Cocoa's creators, as well as illustrate some of the powerful design approaches available with a language as dynamic as Objective-C. Understanding the principles involved will help you use the Cocoa tools and frameworks more effectively, providing the experience you need to work with them instead of against them.

Cocoa's Collection Classes

Several classes in Cocoa's Foundation framework create objects whose purpose is to hold other objects (literally, references to objects); these classes are called collection classes. The two most commonly used collection classes are NSArray and NSDictionary. NSArray stores and retrieves objects in an ordered fashion through zero-based indexing. Dictionaries store and retrieve objects using key-value pairs. These collection classes, shown in Figure 6-1, are extremely useful in Cocoa application development.

Figure 6.1. Cocoa collection classes

Collection classes come in two forms, mutable and immutable. The immutable versions of these classes (NSArray and NSDictionary, for example) allow you to add items when the collection is created but no further changes are allowed. The mutable versions (NSMutableArray, NSMutableDictionary) allow you to add and remove objects programmatically after the collection object is created.

All collection objects enable you to access a contained value that satisfies a particular external property. This property, generally referred to as a key, varies according to the organizing scheme enforced by the type of collection. For example, the key for an array is an integer that specifies position within the collection; however, a dictionary--for which the term key has more of a conventional meaning--permits any arbitrary value to act as the key for retrieving a contained value.

In addition to storage and retrieval using keys, much of the power of collection classes lies in their ability to manipulate the objects they contain. The collection classes implement methods for performing a variety of functions on the objects they contain. Not every collection object can perform every function, but in general, collection objects can:

  • Derive their initial contents from files and URLs as well as other collections of objects

  • Add, remove, locate, and sort their contents

  • Compare their contents with other collection objects

  • Enumerate over their contents

  • Send a message to their contents

  • Store their contents to a file on disk and later retrieve it (with the help of NSArchiver/NSUnarchiver)

Because you will use collection objects frequently when building Cocoa applications, it's important to get a basic feel for how they work. Exploring the collection classes will also provide an opportunity to exercise your Objective-C and Project Builder skills.

Working with NSArray

In this section you will modify the Hello World application from Chapter 5, "Hello World", so that it instantiates and exercises an instance of the NSMutableArray class:

  1. Open the Hello World project if it is not already open.

  2. Open main.m and add a declaration for an NSMutableArray just after the declaration of the autorelease pool and before the call to NSLog:

    NSMutableArray *myArray;
    
  3. Add the code to create a new array:

    myArray = [[NSMutableArray alloc] init];
    
  4. Add code to print the contents of the array object. In this call to NSLog, the %@ is replaced by the object. The %@ works exactly as it would in a printf call; %@ is the escape for an object value, in this case, an NSString. Note that NSLog automatically sends the description message to the array so that information about the array's contents will be printed:

    NSLog(@"Array description: %@ items.\n", myArray);
    
  5. Add code to release the array. This statement tells the runtime that we are finished with the array so it can be safely deallocated:

    [myArray release];
    

Your main function should look exactly like that in Example 6-1.

Example 6.1. Creating a Mutable Array

int main (int argc, const char *argv[]) 
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSMutableArray *myArray;

    NSLog(@"Hello World: This is a Foundation Tool.\n");

    myArray = [[NSMutableArray alloc] init];

    NSLog(@"Array description: %@ items.\n", myArray);

    [myArray release];
    [pool release];
    return 0;
}

Build and run the application. You should see a new string in the Run pane similar to this:

Nov 10 15:56:12 HelloWorld[256] Array description: () items.

Right now, the array is empty, but when you add items, their descriptions will appear between the parentheses.

Spend a few minutes playing with NSMutableArray. Here are some suggestions:

  • Add a string. Note that arrays retain but do not copy their member objects. See "Build and debug the application" later in this chapter for more information.

    [myArray addObject: @"Here's a string!"];
    
  • Find out how many items are in the array:

    int itemCount;
    itemCount = [myArray count];
    
  • Get an object from the array:

    NSString *myString;
    myString = [myArray objectAtIndex: 0];
    
  • Insert an object:

    [myArray insertObject: @"Hello2" atIndex: 0];
    
  • Swap items:

    [myArray exchangeObjectAtIndex: 0 withObjectAtIndex: 1];
    

Consult the class specifications for NSArray and NSMutableArray in /Developer/Documentation/Cocoa for comprehensive documentation on all of the methods for this container class.

Working with NSDictionary

A dictionary--an object of the NSDictionary or NSMutableDictionary class--is a hashing-based collection whose keys for accessing its values are arbitrary, program-defined pieces of data. Although the key is usually a string (an NSString object), it can be any object--with certain caveats: the object used as a key must conform to the NSCopying protocol and respond to the isEqual: message). The keys of dictionaries are unlike the keys of the other collection objects in that, conceptually, they are also contained by the collection along with the values. Dictionaries are primarily useful for holding and organizing data that can be labeled, such as values extracted from text fields in the user interface.

In Cocoa, a dictionary differs from an array in that the key used to access a particular value in the dictionary remains the same as values are added to or removed from the dictionary--until a value associated with a particular key is replaced or removed. In an array, the key (the index) that is used to retrieve a particular value can change over time as values are inserted into or deleted from the array. Also, unlike an array, a dictionary does not put its values in any order. To enable later retrieval of a value, the key of the key-value pair should be constant (or be treated as constant); if the key changes after being used to put a value in the dictionary, the value might not be retrievable. The keys of a dictionary form a set; in other words, keys are guaranteed to be unique in a dictionary.

Working with dictionaries

In this section you will again modify the Hello World application so that it instantiates and exercises an instance of the NSMutableDictionary class:

  1. Open the Hello World project if it is not already open, and bring up main.m for editing.

  2. Add a declaration for a local variable of type NSMutableDictionary:

    NSMutableDictionary *myDict;
    
  3. Add the code to create a new dictionary:

    myDict = [[NSMutableDictionary alloc] init];
    
  4. Add code to print the contents of the dictionary object:

    NSLog(@"Dict description: %@ items.\n", myDict);
    
  5. Add code to release the dictionary:

    [myDict release];
    

Spend a few minutes playing with NSMutableDictionary. Here are some suggestions:

  • Add a key-value pair:

    [myDict setObject:@"stringOne" forKey:@"keyOne"];
    
  • Get an object from the dictionary using its key:

    myString = [myDict objectForKey:@"keyOne"];
    
  • Add several different key-value pairs to the dictionary and then get an array of all the keys. Use a loop to print them all out:

    keyArray = [myDict allKeys];
    for (index = 0; index < [keyArray count]; index++)
        NSLog(@"Dictionary key at index %i is: %@.\n", index, 
            [keyArray objectAtIndex: index]);
    

Consult the class specifications for NSDictionary and NSMutableDictionary for comprehensive documentation on all methods for this container class.

Create Graphical User Interfacesin Cocoa

In this section you'll see how Cocoa and Interface Builder combine to simplify and accelerate the process of constructing applications with a graphical user interface. You'll learn about:

  • Windows. A window is an area on the screen (usually, but not always, rectangular) in which an application displays things such as controls, fields, text, and graphics.

  • Nib files. Nib files are files created by Interface Builder that contain windows as well as other user interface objects.

  • Outlets. Outlets are special instance variables created by Interface Builder that allow objects to send messages to one another.

Finally, you'll apply what you've learned by creating a Cocoa application that displays a window with a single text field containing the current date and time....

Read More Show Less

Table of Contents

Preface;
Organization of This Book;
Conventions Used in This Book;
How to Contact Us;
Cocoa Overview;
Chapter 1: Introduction to Cocoa;
1.1 Cocoa Features;
1.2 The Cocoa Frameworks;
Chapter 2: Object-Oriented Programming;
2.1 The Advantages of Object-Oriented Programming;
2.2 Fundamental Object-Oriented Concepts;
Chapter 3: Objective-C Primer;
3.1 Language Summary;
3.2 Objective-C in Action;
Chapter 4: Development Tools;
4.1 Project Builder;
4.2 Interface Builder;
4.3 Other Development Tools;
4.4 Useful Command-Line Tools;
Single-Window Applications;
Chapter 5: Hello World;
5.1 Creating the Project;
Chapter 6: Essential Cocoa Paradigms;
6.1 Cocoa’s Collection Classes;
6.2 Create Graphical User Interfaces in Cocoa;
6.3 Controls, Cells, and Formatters;
6.4 Target/Action;
6.5 Object Ownership, Retention, and Disposal;
Chapter 7: Currency Converter Tutorial;
7.1 Design the Currency Converter Application;
7.2 Create the Currency Converter Project;
7.3 Create the Currency Converter Interface;
7.4 Define the Classes of Currency Converter;
7.5 Connect ConverterController to the Interface;
7.6 Implement the Classes of Currency Converter;
Chapter 8: Event Handling;
8.1 Respond to User-Generated Events;
8.2 Respond to Program-Generated Events;
Chapter 9: Data Functionality;
9.1 Table Views and Data Sources;
9.2 Flatten the Object Network: Coding and Archiving;
Chapter 10: Travel Advisor Tutorial;
10.1 Travel Advisor Design;
10.2 Create the Travel Advisor Interface;
10.3 Define the Classes of Travel Advisor;
10.4 Implement the Classes of Travel Advisor;
Multiple-Window Applications;
Chapter 11: Cocoa’s Multiple-Document Architecture;
11.1 Architectural Overview;
11.2 Implement a Document-Based Application;
Chapter 12: To Do: Basics;
12.1 The Design of To Do;
12.2 Build the Application;
Chapter 13: To Do: Extended;
13.1 Create and Manage an Info Window;
13.2 Create SelectionNotifyMatrix;
13.3 Data Synchronization;
13.4 Create a Custom View to Display ToDoItem Status;
13.5 Set Up Timers;
13.6 Implement Archiving and Unarchiving (Save and Open);
Chapter 14: To Do: Finishing Touches;
14.1 Configure Application Settings;
14.2 Add an Application Icon;
14.3 Define a Document Type for To Do;
14.4 Enable Compiler Optimization;
Reference;
Drawing in Cocoa;
Coordinate Systems;
Transformation Matrices;
NSView;
Draw NSStrings;
NSBezierPath;
Draw with NSBezierPath;
Draw with Quartz Primitives;
Colophon;

Read More Show Less

Customer Reviews

Average Rating 3
( 2 )
Rating Distribution

5 Star

(1)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(1)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted September 24, 2002

    Great for Programmers

    It take a few days to get on with this book but once you start you will not put the book down until you experience the Cocoa programming. It is great to have other resources from Apple to help out throughout the reading.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted August 2, 2001

    WOW - What a letdown!

    ordered this book a couple of months in advance before the book shipped. I could hardly wait until the day it arrived. But not long afterwards did I realize that this book is one of the biggest disappoints in programming guides I have ever experienced. You can obviously tell that a single person did not work exclusively on this book. Several chapters are in different writing styles... --And the book contained a couple of chapters I had previously downloaded from Apple's site! This book did little for me in advancing my knowledge of Cocoa and Objective C. It is probably and excellent book for someone coming from the NextStep/OpenStep world, but not for someong new to Mac OS X and Objective C. I found the book unorganized with the subject matter presented in an awkward flow. I am a just becoming exposed to Mac OS X Cocoa programming, but am not by any means an inexperienced professional programmer. Perhaps a more appropriate title should have been, 'Cocoa - A Primer For Experienced NextStep/OpenStep Programmers'. And what's with the lame Hello World program you first develop? You write a program to print a message to the debug log in the Project Builder environment. That's a program? And what about packaging your applications, creating icons, and whole other slew of potpurri and developmental aspects? These are just about completely ignored. This book is better than nothing... --but not by much. I hope an individual author (OUTSIDE OF APPLE!) writes a book on Cocoa soon. I'm still waiting (and growing impatient) for a great book on Mac OS X Cocoa programming. What was Apple thinking when they released this book to O'Reilley?

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)