As a web developer, I was a little worried about picking up a compiled language to add to my toolbelt, since the paradigm is so much different from the normal scripting and object oriented programming I'm used to, but so far "Cocoa Programming: A quick start guide for developers" has been an excellent introduction. I am a big fan of PragProg books in general and this book is no exception. Written in a clear and conversation tone, this book is helping me get up to speed with the Cocoa framework from the very practical point-of-view of the XCode/InterfaceBuilder workflow and introducing Objective-C concepts in a way that is illuminating and not intimidating. Its not a deep resource manual, there are other books that do that, but if you're looking to see what is like to build OS X applications, this is a great first step. Contents......Page 7 Moving In......Page 15 Learning the Language......Page 18 Installing the Tools......Page 19 Exploring the Frameworks......Page 20 In This Book......Page 21 Using What's There......Page 24 Creating Your Project in Xcode......Page 25 Creating the Appearance with Interface Builder......Page 26 Testing the Interface with the Cocoa Simulator......Page 31 Finishing the Interface......Page 33 Wiring Up the Components......Page 35 Fixing the Build......Page 39 Sharing Your Browser......Page 41 Exercise: Rinse and Repeat......Page 42 The Nib File......Page 43 Sending Messages Without Arguments......Page 48 Reading the Docs......Page 50 Methods with Arguments......Page 53 Dynamic Binding......Page 56 Problems Sending Messages......Page 57 Links Back to Yourself......Page 58 Exercise: Multiple Connections......Page 59 Creating ``Hello, World!''......Page 62 Logging Output to the Console......Page 63 Using an Existing Class......Page 66 Refactoring Code......Page 69 Creating a New Class......Page 72 Creating and Using a Class Method......Page 75 Creating a New Object......Page 76 Further Refactoring......Page 78 Initializing Your Objects......Page 79 Logging Objects......Page 82 Exercise: Other Initializations......Page 83 Solution: Other Initializations......Page 84 Instance Variables and Properties......Page 86 Pointers......Page 87 Working with Nonobject Types......Page 88 Getters and Setters......Page 89 Converting the Accessors to Properties......Page 92 Dot Notation......Page 93 Property Attributes......Page 96 Exercise: Adding Properties......Page 98 Solution: Adding Properties......Page 99 Removing Instance Variables......Page 100 Memory......Page 102 Reference Counting......Page 103 Finding Leaks with the Clang Static Analyzer......Page 104 Fixing the Memory Leak on Mac OS X......Page 106 Properties and Garbage Collection......Page 107 Creating a Flashlight......Page 109 Finding Leaks in Instruments......Page 111 Fixing the Memory Leak on the iPhone......Page 112 Using Zombies......Page 113 Cleaning Up in dealloc......Page 115 Retain and Release in a Setter......Page 116 The Autorelease Pool......Page 117 Using Convenience Constructors......Page 120 Exercise: Creating and Using a Convenience Constructor......Page 121 Solution: Creating and Using a Convenience Constructor......Page 122 Outlets and Actions......Page 124 Using an Outlet......Page 125 Exercise: Creating and Using an Outlet......Page 128 Solution: Creating and Using an Outlet......Page 129 Declaring an Action......Page 130 Connecting and Implementing the Action......Page 133 Solution: Hiding the Button......Page 135 Solution: Toggling the Interface......Page 136 Introducing Another Outlet......Page 137 Creating Selectors from Strings......Page 139 How We've Created Objects......Page 141 Creating Our Controller Class......Page 143 Creating an Instance of Our Controller in IB......Page 144 Declaring an Outlet and an Action......Page 146 Forward Declaration......Page 149 Exercise: Finishing the Controller......Page 150 Solution: Finishing the Controller......Page 151 Awake from Nib......Page 152 Disabling and Enabling the Buttons......Page 153 Still Needs Work......Page 156 Understanding Delegates......Page 158 Turning the Background Red......Page 162 Application Delegate......Page 165 Delegates for Your Web View......Page 166 Setting the Window Title......Page 167 Exercise: Updating the URL and Setting Buttons......Page 169 Cleaning Up......Page 170 Solution: Adding a Progress Indicator......Page 173 Creating the iPhone Project......Page 175 Creating the Look of Our Browser......Page 177 The WebView's Limitations......Page 178 Loading a Web Page at Launch......Page 179 Tweaking the Text Field in IB......Page 181 Using the Text Field Delegate......Page 183 Using a Third Delegate to Implement the Buttons......Page 184 Exercise: Adding an Activity Indicator......Page 185 Solution: Adding an Activity Indicator......Page 186 Organizing with Pragma Marks......Page 188 Posting and Listening for Notifications......Page 191 Solution: Creating a Model......Page 192 Registering for Notifications......Page 194 Responding to Workspace Activity......Page 195 Holding on to the Controller......Page 197 Solution: Registering for Notifications......Page 198 Posting Notifications......Page 199 Solution: Receiving the Custom Notifications......Page 201 Creating Protocols for Delegation......Page 203 Solution: Creating and Setting the Delegate......Page 204 Creating and Using a Protocol......Page 205 Requiring Methods......Page 207 Exercise: Calling the Delegate Methods......Page 208 Solution: Cleaning Up......Page 209 Looking at the User Info......Page 213 Reading from a Dictionary......Page 214 Solution: Displaying the Name......Page 215 Reducing Redundancy......Page 216 Adding and Removing Entries with a Mutable Dictionary......Page 218 Exercise: Adding an Icon......Page 221 Solution: Adding an Icon......Page 223 Methods, Objects, and Nibs......Page 227 Splitting Nibs......Page 229 Preparing to Split Out the View......Page 231 Creating the View Nib......Page 232 Integrating a Nib File......Page 233 The File's Owner......Page 235 Exercise: Loading the View......Page 236 Creating the Window Nib......Page 237 Loading the Window Nib......Page 239 Exercise: Connecting the View and the Model......Page 240 Solution: Connecting the View and the Model......Page 241 Creating a Custom View......Page 243 Drawing Shapes into a Custom View......Page 245 Solution: Changing the Stroke Color......Page 248 Drawing Images......Page 250 Drawing Text......Page 252 Tables and Data Sources......Page 256 Exercise: Implementing a Basic Data Source......Page 259 Solution: Implementing a Basic Data Source......Page 260 Exercise: Introducing a Data Source......Page 261 Solution: Introducing a Data Source......Page 262 Filling Cells Based on Table Column Titles......Page 263 Table Column Identifiers as Keys......Page 265 Exercise: Adding and Removing Rows......Page 266 Solution: Adding and Removing Rows......Page 267 Manually Removing Rows......Page 268 Saving in Your Running Application......Page 270 Where to Put Application Support......Page 273 Saving to a Plist......Page 274 Reading a Plist......Page 275 Saving an Archive to Disk......Page 276 Setting the Factory Defaults......Page 278 Preparing to Set User Defaults......Page 280 The Preference Window Nib......Page 281 Enabling the Preferences Window......Page 283 Working with Radio Buttons......Page 285 Adding Preferences for View at Launch......Page 287 Solution: Launching with the Right View......Page 288 Eliminating Magic Numbers......Page 290 Customizing the Menu Bar......Page 292 Moving the Main Window......Page 293 Solution: Switching Views (Mostly)......Page 294 Lazy Initialization......Page 296 Key Value Coding......Page 298 Treating Objects Like Dictionaries......Page 299 Getting Variables Using KVC......Page 301 Undefined Keys......Page 303 Solution: Setting Variables Using KVC......Page 304 KVC and Dictionaries......Page 305 Keypaths for Navigating a Class Hierarchy......Page 306 Solution: Filling Tables Using KVC......Page 309 Arrays and KVC......Page 311 Codeless Connections......Page 314 A Target-Action Counter......Page 316 Introducing an Observer......Page 318 Registering an Observer......Page 320 Making Changes Observable......Page 321 Observing the Changes......Page 323 Solution: Adding a Second Observer......Page 324 The Ugly Way to Observe More Than One Attribute......Page 325 Selecting Methods Using KVC......Page 328 Implementing an Observer Object......Page 329 Updating Dependent Variables......Page 331 Cocoa Bindings......Page 334 Creating and Connecting the NSObjectController......Page 335 Binding More Objects......Page 338 Number Formatters......Page 339 Exercise: Connecting Two Counters with Bindings......Page 341 Solution: Connecting Two Counters with Bindings......Page 342 The Model for Our Bookshelf Example......Page 344 Creating the View for the Bookshelf......Page 345 Binding with the NSArrayController......Page 346 The Big Finish......Page 349 Core Data......Page 350 Entities and Attributes......Page 351 Using the Core Data Widget......Page 352 The Managed Object Context......Page 354 The Persistence Layer......Page 356 Introducing Relationships......Page 358 Choosing a Relationship's Delete Rule......Page 360 Updating the View......Page 361 Managing Dependencies......Page 362 Sorting......Page 363 Filtering Items......Page 365 Coding the Sort Descriptor......Page 366 Overcoming Limitations......Page 368 Creating a Category......Page 369 Category Cautions......Page 371 Private Methods in Class Extensions......Page 372 Solution: Extending Properties with Class Extensions......Page 375 Categories and Core Data......Page 376 Generated Classes in Core Data......Page 378 Accessing Properties......Page 379 Regenerating Class Files from Entities......Page 380 Blocks......Page 383 The Need for Blocks in Wrappers......Page 384 Declaring a Block......Page 385 Using Blocks in Wrappers......Page 386 Capturing Values......Page 387 Blocks and Collections......Page 389 Declaring, Defining, and Using Blocks......Page 390 Using __block......Page 392 Cleaning Up with typedef......Page 393 Exercise: Using Blocks in Callbacks......Page 394 Solution: Using Blocks in Callbacks......Page 396 Making the Beach Ball Spin......Page 398 Invocation Operations......Page 400 Block Operations......Page 402 Interacting with the Queue and Operations......Page 403 Custom NSOperations......Page 406 From Operation Queues to Dispatch Queues......Page 408 When to Use Dispatch Queues......Page 412 Quick Queue Overview......Page 414 Drawing Our Fractal......Page 415 Working Without Dispatch Queues......Page 416 The Main Queue......Page 418 Global Concurrent Queues......Page 419 Synchronizing on the Main Queue......Page 420 Private Dispatch Queues......Page 421 Synchronous Tasks......Page 422 But What About.........Page 426 What's Next......Page 427 Acknowledgments......Page 428 Dedication......Page 429 Bibliography......Page 431 A......Page 434 C......Page 435 D......Page 437 E......Page 438 I......Page 439 L......Page 440 M......Page 441 N......Page 442 O......Page 443 P......Page 444 R......Page 445 S......Page 446 V......Page 447 Y......Page 448 Z......Page 449
Cocoa Programming: A Quick-Start Guide for Developers shows you how to get productive with Cocoa-fast! We won't walk you through every class and method in the API (but we will show you where to find that information). Instead, we'll jump right in and start building a web browser using Cocoa. In just a few minutes you'll have something that works. A couple of minutes more, and you'll have code in your custom controller, listening for notifications and call-backs. Soon you'll have the functionality you'd expect in a full browser. And that's just the first few chapters...
Apple's Cocoa frameworks let you write powerful and attractive applications for Mac OS X or the iPhone. With this book plus your existing knowledge of object-oriented programming you can take advantage of Cocoa and create compelling, feature rich, compliant Mac applications for this industry-leading environment