Cocoa Programming for Mac OS X

by
Format: Paperback
Pub. Date: 2001-12-01
Publisher(s): Addison-Wesley Professional
  • Free Shipping Icon

    This Item Qualifies for Free Shipping!*

    *Excludes marketplace orders.

List Price: $47.24

Rent Book

Select for Price
There was a problem. Please try again later.

New Book

We're Sorry
Sold Out

Used Book

We're Sorry
Sold Out

eBook

We're Sorry
Not Available

How Marketplace Works:

  • This item is offered by an independent seller and not shipped from our warehouse
  • Item details like edition and cover design may differ from our description; see seller's comments before ordering.
  • Sellers much confirm and ship within two business days; otherwise, the order will be cancelled and refunded.
  • Marketplace purchases cannot be returned to eCampus.com. Contact the seller directly for inquiries; if no response within two days, contact customer service.
  • Additional shipping costs apply to Marketplace purchases. Review shipping costs at checkout.

Summary

Apple's Cocoa framework and tools are indispensable to every developer who wants to take full advantage of Mac OS X's features and performance, and get applications to market rapidly. However, Cocoa has a steep learning curve, and the official documentation leaves much to be desired. Now, Cocoa insider Aaron Hillegass presents the first start-to-finish guide for serious Cocoa development. In this book, Hillegass leverages his experience as the creator of the world's first independent Cocoa training course, anticipating the questions that real-world developers ask about Cocoa -- and offering deep insight into the design patterns that give Cocoa its extraordinary power and elegance. He begins with an overview of Cocoa's goals, capabilities, and toolset. Learn how to use Cocoa's Project Builder to track all of your application's diverse resources, edit code, and compile and run applications. Master the Cocoa Interface Builder: leverage the full capabilities of Mac OS X's breakthrough Aqua interface, then go beyond "windows and widgets" to create classes and edit their attributes. Hillegass gives experienced C and object-oriented developers all the skills they need to use Objective-C, the preferred language for Cocoa development. Coverage includes: custom views; responders and keyboard events; fonts and NSString; pasteboards; categories; compilation with the GNU C (gcc) compiler; debugging with the GNU debugger (gdb); and much more. The book includes extensive code examples; most in Objective-C, some in Java.

Table of Contents

Preface xvii
Acknowledgments xix
Cocoa: What Is It?
1(8)
A Little History
1(2)
Tools
3(1)
Objects, Classes, Methods, and Messages
4(1)
Frameworks
5(1)
How to Read This Book
6(1)
Typographical Conventions
7(1)
How to Learn
7(2)
Let's Get Started
9(24)
In Project Builder
9(4)
Create a New Project
9(3)
The main Function
12(1)
In Interface Builder
13(11)
The Standard Palettes
15(1)
The Blank Window
15(1)
Lay Out the Interface
16(1)
The Document Window
17(1)
Create a Class
18(3)
Create an Instance
21(1)
Make Connections
21(3)
Back in Project Builder
24(6)
Types and Constants in Objective-C
26(1)
Edit the Header File
26(1)
Edit the Implementation File
27(1)
Build and Run
28(1)
awakeFromNib
29(1)
Documentation
30(1)
What Have You Done?
30(3)
Objective-C
33(40)
Creating and Using Instances
33(2)
Using Existing Classes
35(14)
Memory Management: Retain Count, Releasing, and Retaining
40(2)
Sending Messages to nil
42(1)
Declaring Variables
43(1)
NSObject, NSArray, NSMutableArray, and NSString
43(1)
NSObject
43(2)
NSArray
45(2)
NSMutableArray
47(1)
NSString
47(1)
``Inherits From'' Versus ``Uses'' or ``Knows About''
48(1)
Creating Your Own Classes
49(18)
Creating the LotteryEntry Class
49(1)
LotteryEntry.h
49(3)
LotteryEntry.m
52(1)
dealloc
53(1)
Changing main.m
54(1)
Implementing a description Method
55(1)
Creating Autoreleased Objects
56(5)
NSCalendarDate
61(3)
Writing Initializers
64(2)
Initializers with Arguments
66(1)
The Debugger
67(3)
What Have You Done?
70(1)
For the More Curious: How Does Messaging Work?
71(1)
Challenge
72(1)
Controls
73(30)
Some Commonly Used Subclasses of NSControl
75(4)
NSButton
75(2)
NSSlider
77(1)
NSTextfield
78(1)
Start the RaiseMan Example
79(2)
The Interface File for MyDocument
81(2)
Lay Out the Interface
83(11)
Using the Info Panel
86(1)
Adding a Formatter
87(1)
Making Connections
88(4)
NSWindow's initialFirstResponder Outlet
92(1)
NSView's nextKey View Outlet
92(2)
Edit the Main Menu
94(1)
Implementing the Person Class
94(2)
Implementing the MyDocument Class
96(4)
What Have You Done?
100(1)
For the More Curious: Setting the Target Programmatically
101(1)
Challenge
101(2)
Helper Objects
103(18)
NSTableView and Its Data Source
104(1)
MyDocument Interface File
105(1)
Lay Out the User Interface
106(3)
Make Connections
109(2)
Edit MyDocument.m
111(2)
Key-value Coding
113(2)
Delegates
115(3)
Common Errors in Implementing a Delegate
117(1)
Which Objects Have Delegates?
117(1)
Retain Cycles
118(1)
For the More Curious: How Delegates Work
118(1)
Challenge 1
119(1)
Challenge 2
119(2)
Archiving
121(18)
NSCoder and NSCoding
122(3)
Encoding
123(1)
Decoding
124(1)
The Document Architecture
125(3)
Info.plist and NSDocumentController
125(1)
NSDocument
126(1)
Saving
126(1)
Loading
127(1)
NSWindowController
128(1)
Saving and NSArchiver
128(1)
Loading and NSUnarchiver
129(1)
Informing the Document That It Has Been Edited
130(1)
Setting the Extension and Icon for the File Type
131(3)
For the More Curious: Preventing Infinite Loops
134(1)
For the More Curious: Versioning
135(1)
For the More Curious: Creating a Protocol
136(3)
Nib Files and NSWindowController
139(16)
NSPanel
139(1)
Adding a Panel to the Application
140(12)
MainMenu.nib
140(2)
Setting Up the Menu Item
142(3)
AppController.m
145(1)
Preferences.nib
145(2)
File's Owner
147(1)
Lay Out the User Interface
148(3)
PreferenceController.m
151(1)
For the More Curious: NSBundle
152(2)
Challenge 1
154(1)
Challenge 2
154(1)
User Defaults
155(1)
NSDictionary and NSMutableDictionary
155(3)
NSDictionary
157(1)
NSMutaleDictionary
158(1)
NSUserDefaults
158(2)
Precedence of Different Types of Defaults
160(1)
Creating Keys for the Names of the Defaults
160(1)
Registering Defaults
161(1)
Let the User Edit the Defaults
161(2)
Using the Defaults
163(2)
Suppressing the Creation of Unititled Documents
163(1)
Setting the Background Color on the Table View
164(1)
Saving the Frame of a Window
165(1)
For the More Curious: Reading and Writing Defaults from the Command Line
165(1)
Challenge
166(1)
Using Notifications
167(8)
What Notifications Are
167(1)
What Notifications Are Not
168(1)
NSNotification
168(1)
NSNotificationCenter
168(3)
Posting a Notification
171(1)
Registering As an Observer
171(1)
Unregistering the Observer
172(1)
Handling the Notification When It Arrives
172(1)
For the More Curious: Delegates and Notifications
173(1)
For the More Curious: The userInfo Dictionary
173(1)
Challenge
174(1)
Using Alert Panels
175(4)
Make the User Confirm the Delete
176(2)
Challenge
178(1)
Localization
179(10)
Localizing a Nib File
180(2)
String Tables
182(3)
Creating String Tables
182(3)
Using the String Table
185(1)
For the More Curious: nibtool
185(2)
Challenge
187(2)
Custom Views
189(16)
The View Hierarchy
189(2)
Get a View to Draw Itself
191(6)
Create an Instance of a View Subclass
193(1)
Size Info
194(1)
drawRect:
194(3)
Drawing with NSBezierPath
197(2)
NSScrollView
199(2)
For the More Curious: Cells
201(3)
Challenge
204(1)
Images and Mouse Events
205(18)
NSResponder
205(1)
NSEvent
205(2)
Getting Mouse Events
207(1)
Using NSOpenPanel
207(8)
Change the Nib File
209(3)
awakeFromNib Versus init
212(1)
Edit the Code
213(2)
Composite an Image Onto Your View
215(2)
The View's Coordinate System
217(3)
Autoscrolling
220(1)
For the More Curious: NSImage
220(1)
Challenge
221(2)
Responders and Keyboard Events
223(14)
NSResponder
224(2)
NSEvent
226(1)
Create a New Project with a Custom View
226(11)
Edit the Nib File
226(3)
Lay Out the Interface
229(1)
Size Info
230(1)
Make Connections
230(2)
Writing the Code
232(1)
In BigLetterView.h
232(2)
In BigLetterView.m
234(3)
Working with Fonts and NSString
237(10)
NSFont
237(1)
Commonly Used Methods in NSFont
237(1)
NSAttributedString
238(2)
Drawing Strings and Attributed Strings
240(1)
Making Letters Appear
241(2)
Getting Your View to Generate PDF Data
243(2)
For the More Curious: NSFontManager
245(1)
Challenge 1
246(1)
Challenge 2
246(1)
Pasteboards and Nil-Targeted Actions
247(10)
NSPasteboard
248(1)
Add Cut, Copy, and Paste to BigLetterView
249(2)
Nil-Targeted Actions
251(3)
Looking at the Nib File
252(2)
For the More Curious: Which Object Really Sends the Action Message?
254(1)
For the More Curious: Lazy Copying
254(1)
Challenge
255(2)
Categories
257(4)
Add a Method to NSString
257(4)
Drag-and-Drop
261(8)
Make BigLetterView a Drag Source
261(3)
Make BigLetterView a Drag Destination
264(4)
registerForDraggedTypes:
264(1)
Add Highlighting
265(1)
Implement the Dragging Destination Methods
266(1)
Test It
267(1)
Challenge
268(1)
NSTimer
269(10)
Lay Out the Interface
269(2)
Make Connections
271(2)
Adding Code to AppController
273(3)
Challenge
276(3)
Sheets
279(12)
Adding a Sheet
280(6)
Add Outlets and Actions
280(1)
Lay Out the Interface
281(2)
Adding Code
283(3)
For the More Curious: contextInfo
286(1)
For the More Curious: NSDrawer
287(1)
Challenge
288(3)
Creating NSFormatters
291(14)
A Basic Formatter
292(7)
Edit the Interface File for the AppController Class
293(1)
Editing the Nib File
294(1)
NSColorList
294(1)
Searching Strings for Substrings
295(1)
Create a Subclass of NSFormatter
296(3)
The Delegate of the NSControl
299(1)
Checking Partial Strings
300(1)
The Control's Delegate and Partial Strings
301(1)
Formatters That Return Attributed Strings
302(1)
Challenge
302(3)
Printing
305(10)
Adding Printing to Typing Tutor
305(2)
Dealing with Pagination
307(6)
Challenge
313(2)
Updating Menus
315(6)
Making a BigLetterView Uncopyable
316(5)
Working with NSTextView
321(20)
NSTextView
322(1)
Messages the Delegate Will Be Sent
323(1)
Build the Editor with Which This Book Was Written
324(13)
Read, Write, and Edit Text Files
324(5)
Adding a Context-Sensitive Menu
329(3)
Adding the Menu
332(3)
Creating the NSMenu
335(1)
Replace the Selection
336(1)
Overriding menuForEvent:
337(1)
For the More Curious: The Field Editor
337(4)
Using Java with Cocoa
341(8)
Don't Use Java to Write Cocoa Applications
341(1)
If You Must Use Java to Write Cocoa Applications
342(7)
Create a New Project and Lay Out the Interface
342(2)
Make Connections
344(2)
Back in Project Builder
346(1)
Subclassing Cocoa Classes in Java
347(1)
Documentation
348(1)
Creating Interface Builder Palettes
349(20)
Add NSCoding Methods to BigLetterView
350(2)
Create a Palette Project
352(2)
Edit the Nib File for Your Palette
354(1)
palette.table
354(2)
Build and Test
356(1)
finishInstantiate
357(1)
Adding an Inspector
358(7)
Create a Nib File for Your Inspector
359(2)
Code for an Inspector
361(4)
For the More Curious: How to Palettize Objects That Are Not Views
365(2)
Challenge
367(2)
The End
369(2)
Index 371

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

Digital License

You are licensing a digital product for a set duration. Durations are set forth in the product description, with "Lifetime" typically meaning five (5) years of online access and permanent download to a supported device. All licenses are non-transferable.

More details can be found here.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.