Preface xvii Acknowledgments xix Chapter 1: Cocoa: What Is It? 1 A Little History 1 Tools 3 Language 4 Objects, Classes, Methods, and Messages 4 Frameworks 6 How to Read This Book 6 Typographical Conventions 7 Common Mistakes 7 How to Learn 8 Chapter 2: Let''s Get Started 9 In Xcode 9 In Interface Builder 13 Back in Xcode 23 Documentation 29 What Have You Done? 30 Chapter 3: Objective-C 33 Creating and Using Instances 33 Using Existing Classes 35 Creating Your Own Classes 46 The Debugger 58 What Have You Done? 62 For the More Curious: How Does Messaging Work? 62 Challenge 64 Chapter 4: Memory Management 65 Turning the Garbage Collector On and Off 66 Living with the Garbage Collector 68 Living with Retain Counts 68 What Have You Done? 77 Chapter 5: Target/Action 79 Some Commonly Used Subclasses of NSControl 81 Start the SpeakLine Example 85 Lay Out the Nib File 86 Implementing the AppController Class 88 For the More Curious: Setting the Target Programmatically 90 Challenge 90 Debugging Hints 92 Chapter 6: Helper Objects 95 Delegates 96 The NSTableView and Its dataSource 99 Lay Out the User Interface 102 Make Connections 103 Edit AppController.m 105 For the More Curious: How Delegates Work 108 Challenge: Make a Delegate 109 Challenge: Make a Data Source 110 Chapter 7: Key-Value Coding; Key-Value Observing 111 Key-Value Coding 111 Bindings 113 Key-Value Observing 115 Making Keys Observable 116 Properties and Their Attributes 118 For the More Curious: Key Paths 120 For the More Curious: Key-Value Observing 121 Chapter 8: NSArrayController 123 Starting the RaiseMan Application 124 Key-Value Coding and nil 132 Add Sorting 133 For the More Curious: Sorting without NSArrayController 134 Challenge 1 135 Challenge 2 135 Chapter 9: NSUndoManager 139 NSInvocation 139 How the NSUndoManager Works 140 Adding Undo to RaiseMan 142 Key-Value Observing 145 Undo for Edits 146 Begin Editing on Insert 149 For the More Curious: Windows and the Undo Manager 151 Chapter 10: Archiving 153 NSCoder and NSCoding 154 The Document Architecture 157 Saving and NSKeyedArchiver 161 Loading and NSKeyedUnarchiver 162 Setting the Extension and Icon for the File Type 163 For the More Curious: Preventing Infinite Loops 166 For the More Curious: Creating a Protocol 167 For the More Curious: Document-Based Applications without Undo 167 Universal Type Identifiers 168 Chapter 11: Basic Core Data 171 NSManagedObjectModel 171 Interface 173 How Core Data Works 180 Chapter 12: Nib Files and NSWindowController 183 NSPanel 183 Adding a Panel to the Application 184 For the More Curious: NSBundle 194 Challenge 195 Chapter 13: User Defaults 197 NSDictionary and NSMutableDictionary 198 NSUserDefaults 200 Setting the Identifier for the Application 202 Creating Keys for the Names of the Defaults 202 Registering Defaults 203 Letting the User Edit the Defaults 203 Using the Defaults 205 For the More Curious: NSUserDefaultsController 207 For the More Curious: Reading and Writing Defaults from the Command Line 207 Challenge 208 Chapter 14: Using Notifications 209 What Notifications Are 209 What Notifications Are Not 210 NSNotification and NSNotificationCenter 210 Posting a Notification 212 Registering as an Observer 213 Handling the Notification When It Arrives 214 The userInfo Dictionary 214 For the More Curious: Delegates and Notifications 215 Challenge 216 Chapter 15: Using Alert Panels 217 Make the User Confirm the Deletion 218 Challenge 221 Chapter 16: Localization 223 Localizing a Nib File 224 String Tables 226 For the More Curious: ibtool 230 For the More Curious: Explicit Ordering of Tokens in Format Strings 231 Chapter 17: Custom Views 233 The View Hierarchy 233 Getting a View to Draw Itself 235 Drawing with NSBezierPath 240 NSScrollView 242 Creating Views Programmatically 245 For the More Curious: Cells 245 For the More Curious: isFlipped 247 Challenge 248 Chapter 18: Images and Mouse Events 249 NSResponder 249 NSEvent 249 Getting Mouse Events 251 Using NSOpenPanel 251 Composite an Image onto Your View 256 The View''s Coordinate System 258 Autoscrolling 261 For the More Curious: NSImage 261 Challenge 262 Chapter 19: Keyboard Events 263 NSResponder 265 NSEvent 265 Create a New Project with a Custom View 266 For the More Curious: Rollovers 274 The Fuzzy Blue Box 275 Chapter 20: Drawing Text with Attributes 277 NSFont 277 NSAttributedString 278 Drawing Strings and Attributed Strings 280 Making Letters Appear 281 Getting Your View to Generate PDF Data 283 For the More Curious: NSFontManager 286 Challenge 1 286 Challenge 2 286 Chapter 21: Pasteboards and Nil-Targeted Actions 287 NSPasteboard 288 Add Cut, Copy, and Paste to BigLetterView 289 Nil-Targeted Actions 290 For the More Curious: Which Object Sends the Action Message? 293 For the More Curious: Lazy Copying 293 Challenge 1 294 Challenge 2 294