You are previewing Learn Cocoa on the Mac, Second Edition.
O'Reilly logo
Learn Cocoa on the Mac, Second Edition

Book Description

The Cocoa frameworks are some of the most powerful for creating native OS X apps available today. However, for a first-time Mac developer, just firing up Xcode 4 and starting to browse the documentation can be a daunting and frustrating task. The Objective-C class reference documentation alone would fill thousands of printed pages, not to mention all the other tutorials and guides included with Xcode. Where do you start? Which classes are you going to need to use? How do you use Xcode and the rest of the tools?

Learn Cocoa for the Mac, Second Edition, completely revised for OS X Mountain Lion and XCode 4, answers these questions and more, helping you find your way through the jungle of classes, tools, and new concepts so that you can get started on the next great OS X app today. Jack Nutting and Peter Clark are your guides through this forest; Jack and Peter have lived here for years, and will show you which boulder to push, which vine to chop, and which stream to float across in order to make it through. You will learn not only how to use the components of this rich framework, but also which of them fit together, and why.

Jack Nutting's approach, combining pragmatic problem-solving with a deep respect for the underlying design philosophies contained within Cocoa, stems from years of experience using these frameworks. Peter Clark will show you which parts of your app require you to jump in and code a solution, and which parts are best served by letting Cocoa take you where it wants you to go. The path over what looks like a mountain of components and APIs has never been more thoroughly prepared for your travels. In each chapter, you'll build an app that explores one or more areas of the Cocoa landscape. With Jack's and Peter's guidance, the steep learning curve becomes a pleasurable adventure. There is still much work for the uninitiated, but by the time you're done, you will be well on your way to becoming a Cocoa master.

What you'll learn

  • How to effectively use Xcode to make your own Cocoa applications—this is much more than just a quick introduction to Cocoa!

  • How to best use MVC architecture concepts in a Cocoa application

  • Which classes, of the dozens included in Cocoa, are truly central to Cocoa development.

  • How the various pieces of the Cocoa frameworks fit with each other and into the MVC architecture

  • Which parts of Cocoa truly enable "visual programming", letting you reap the benefits of proven, reusable code libraries that Apple gives you for free

  • How to recognize recurring design patterns used throughout Cocoa, such as delegation and key-value coding, and put them to proper use in your own code

  • Where some of the deeper technologies, like Core Data and Cocoa bindings, fit into your app

  • How to use the facilities provided in OS X to create software that distributes itself automatically among all available CPUs, improving the user experience for your users.

  • How to approach Cocoa from different programming environments

  • Who this book is for

    Anyone with a basic understanding of object-oriented programming who wants to try out OS X app programming, as well as iPhone developers who want to extend their knowledge of Cocoa touch to include the Mac-specific technologies included with Cocoa.

    Table of Contents

    1. Title
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. Preface
    6. About the Authors
    7. About the Technical Reviewer
    8. Acknowledgments
    9. Chapter 1: Must Love Cocoa
      1. Get a Mac and Download the Tools
      2. Download the Source Code
      3. Getting Help
      4. What You Need to Know Before You Begin
      5. Are You Ready?
    10. Chapter 2: Hello, World
      1. Building “Hello World”
      2. Exploring the Nib File
      3. Creating the Application Icon
      4. Adding an Icon to our Project
      5. Property Lists
      6. Running the Application
      7. Sharing Our Creation With the World
      8. Goodbye, Hello World
    11. Chapter 3: Lights, Camera...Actions! (and Outlets, too)
      1. Frameworks, Frameworks Everywhere
      2. Outlets, Actions, and Controllers
      3. Outlets and Actions in Action
      4. Wrap Up
    12. Chapter 4: The First Call to Action
      1. Declaring Outlets and Actions
      2. Outlets and Actions in Action, Act 2
      3. Creating the Controller Class
      4. The Application Delegate
      5. Using the Documentation Browser
      6. Wrap Up
    13. Chapter 5: GUI Components
      1. Creating the VillainTracker Application
      2. Wiring Up the VillainTrackerAppDelegate Class
      3. Getting Started with Coding
      4. Wrap Up
    14. Chapter 6: Using Table Views
      1. Preparing VillainTrackerAppDelegate for Multiple Villains
      2. Making Way for the Table View
      3. A Nasty Resize Surprise, or, Constraints To The Rescue!
      4. Making Way for the Table View: Code Edition
      5. Wrap Up
    15. Chapter 7: Cocoa Bindings
      1. Binding to Simple Controls
      2. Binding to a Table View
      3. Okay, But How Did That Work?
      4. Wrap Up
    16. Chapter 8: Core Data Basics
      1. What We’ve Been Missing
      2. Creating MythBase
      3. Designing the GUI
      4. Setting up Cocoa Bindings
      5. Exploring the Template Code
      6. Adding Business Logic
      7. Wrap Up
    17. Chapter 9: Core Data Relationships
      1. Modeling New Entities and Relationships
      2. Updating the GUI
      3. Wrap Up
    18. Chapter 10: Search and Retrieve Core Data with Criteria
      1. Creating QuoteMonger
      2. Limiting Results with NSPredicate
      3. Saving a Predicate
      4. Wrap Up
    19. Chapter 11: Windows and Menus and Sheets
      1. NSWindow and NSPanel
      2. A Controller With a Nib of Its Own
      3. Modal Windows
      4. System Menus
      5. Sheets
      6. Wrap Up
    20. Chapter 12: Document-Based Applications
      1. Creating the ColorMix Application
      2. Setting Two Colors
      3. Settling on a File Format
      4. Adding Color
      5. About Undo and Redo
      6. Wrap Up
    21. Chapter 13: Exceptions, Signals, Errors, and Debugging
      1. Exception Handling
      2. Worse than Exceptions: Death by Signal
      3. NSError
      4. Wrap Up
    22. Chapter 14: Drawing in Cocoa
      1. Fundamentals
      2. Creating an NSView Subclass
      3. LOLmaker
      4. Wrap Up
    23. Chapter 15: Advanced Drawing Topics
      1. Editing a Curve
      2. Core Animation: A Primer
      3. Grouping Animations
      4. Wrap Up
    24. Chapter 16: Working with Files
      1. Implicit File Access
      2. High-Level File Operations
      3. Wrap Up
    25. Chapter 17: Concurrency
      1. SlowWorker
      2. Threading Basics
      3. Vitalizing SlowWorker
      4. GCD: Low-Level Queuing
      5. A Little Concurrency Goes a Long Way
    26. Chapter 18: Future Paths
      1. More Cocoa-isms
      2. Cocoa in a Foreign Language
      3. Ported Cocoa
      4. Here at the End of All Things
    27. Index