You are previewing Beginning, Mac OS® X Snow Leopard™ Programming.
O'Reilly logo
Beginning, Mac OS® X Snow Leopard™ Programming

Book Description

A solid introduction to programming on the Mac OS X Snow Leopard platform

The Mac OS X Snow Leopard system comes with everything you need in its complete set of development tools and resources. However, finding where to begin can be challenging. This book serves as an ideal starting point for programming on the Mac OS X Snow Leopard platform. Step-by-step instructions walk you through the details of each featured example so that you can type them out, run them, and even figure out how to debug them when they don't work right. Taking into account that there is usually more than one way to do something when programming, the authors encourage you to experiment with a variety of solutions. This approach enables you to efficiently start writing programs in Mac OS X Snow Leopard using myriad languages and put those languages together in order to create seamless applications.

Coverage Includes:

  • The Mac OS X Environment

  • Developer Tools

  • Xcode

  • Interface Builder

  • The C Language

  • The Objective-C Language

  • An Introduction to Cocoa

  • Document-Based Cocoa Applications

  • Core Data-Based Cocoa Applications

  • An Overview of Scripting Languages

  • The Bash Shell

  • AppleScript and AppleScriptObjC

  • Javascript, Dashboard, and Dashcode

Note: CD-ROM/DVD and other supplementary materials are not included as part of eBook file.

Table of Contents

  1. Copyright
  2. CREDITS
  3. ABOUT THE AUTHORS
  4. ACKNOWLEDGMENTS
  5. INTRODUCTION
    1. 0.1. WHO THIS BOOK IS FOR
    2. 0.2. HOW THIS BOOK IS STRUCTURED
    3. 0.3. WHAT YOU NEED TO USE THIS BOOK
    4. 0.4. CONVENTIONS
    5. 0.5. SOURCE CODE
    6. 0.6. ERRATA
    7. 0.7. P2P.WROX.COM
  6. I. Mac OS X Developer Resources
    1. 1. The Mac OS X Environment
      1. 1.1. INTRODUCING THE MAC OS X
      2. 1.2. THE CORE OPERATING SYSTEM
        1. 1.2.1. The Kernel
        2. 1.2.2. The System Library
        3. 1.2.3. Unix Commands
      3. 1.3. GRAPHICS AND MEDIA LAYERS
        1. 1.3.1. The Quartz Compositor
        2. 1.3.2. Quartz 2D
        3. 1.3.3. OpenGL
        4. 1.3.4. QuickTime
        5. 1.3.5. Core Animation
      4. 1.4. APPLICATION FRAMEWORKS AND UI
        1. 1.4.1. Cocoa
        2. 1.4.2. Carbon
        3. 1.4.3. Java JDK
      5. 1.5. APPLE HUMAN INTERFACE GUIDELINES
      6. 1.6. SUMMARY
    2. 2. Developer Tools
      1. 2.1. INSTALLING THE DEVELOPER SOFTWARE
      2. 2.2. DEVELOPER APPLICATIONS
        1. 2.2.1. Build Tools
        2. 2.2.2. Performance Tools
          1. 2.2.2.1. Instruments
            1. 2.2.2.1.1. ObjectAlloc and Leaks
            2. 2.2.2.1.2. Time Profiler and Spin Monitor
            3. 2.2.2.1.3. Thread States
            4. 2.2.2.1.4. User Interface
          2. 2.2.2.2. Shark
        3. 2.2.3. Other Utilities
          1. 2.2.3.1. FileMerge
          2. 2.2.3.2. Icon Composer
          3. 2.2.3.3. PackageMaker
          4. 2.2.3.4. Pixie
          5. 2.2.3.5. Property List Editor
          6. 2.2.3.6. Script Editor
        4. 2.2.4. Command-Line Tools
          1. 2.2.4.1. cc/gcc
          2. 2.2.4.2. diff
          3. 2.2.4.3. gdb
          4. 2.2.4.4. sample
          5. 2.2.4.5. sh/bash/tcsh
          6. 2.2.4.6. top
      3. 2.3. DEVELOPER DOCUMENTATION AND EXAMPLES
        1. 2.3.1. Conceptual Documentation
          1. 2.3.1.1. Apple Human Interface Guidelines
          2. 2.3.1.2. Mac OS X Technology Overview
          3. 2.3.1.3. A Tour of Xcode
        2. 2.3.2. API Reference
        3. 2.3.3. Examples
        4. 2.3.4. Man Pages
      4. 2.4. APPLE DEVELOPER CONNECTION
        1. 2.4.1. Documentation
        2. 2.4.2. Examples
        3. 2.4.3. Mailing Lists
        4. 2.4.4. Developer Tools
        5. 2.4.5. Developer Support
      5. 2.5. SUMMARY
    3. 3. Xcode
      1. 3.1. STARTING A NEW PROJECT
      2. 3.2. WORKING WITH FILES
      3. 3.3. WRITING YOUR CODE
        1. 3.3.1. A Second Look at Indenting
      4. 3.4. BUILDING AND RUNNING
      5. 3.5. FINDING PROBLEMS WITH THE STATIC ANALYZER
      6. 3.6. USING THE DEBUGGER
      7. 3.7. ONLINE DOCUMENTATION
      8. 3.8. SUMMARY
    4. 4. Interface Builder
      1. 4.1. STARTING A NEW INTERFACE
      2. 4.2. BUILDING MENUS
      3. 4.3. BUILDING WINDOWS
      4. 4.4. MAKING WINDOWS RESIZABLE
      5. 4.5. SUMMARY
  7. II. Application Programming
    1. 5. The Application
      1. 5.1. BASIC BUNDLE STRUCTURE
        1. 5.1.1. Opaque Directory
        2. 5.1.2. Versioned Bundles
        3. 5.1.3. The Info.plist File
        4. 5.1.4. Executable Code
        5. 5.1.5. Global Resources
        6. 5.1.6. Localized Resources
      2. 5.2. EXAMINING APPLICATION BUNDLES
      3. 5.3. BUILDING AN APPLICATION BUNDLE
      4. 5.4. APPLICATION PREFERENCES
      5. 5.5. SUMMARY
    2. 6. The C Language
      1. 6.1. A LITTLE HISTORY
      2. 6.2. GETTING STARTED
      3. 6.3. VARIABLES AND DATA TYPES
      4. 6.4. OPERATORS
      5. 6.5. ARRAYS AND POINTERS
      6. 6.6. CONDITIONAL BRANCHING
      7. 6.7. LOOPS
      8. 6.8. FUNCTIONS AND BLOCKS
      9. 6.9. CHARACTERS AND STRINGS
      10. 6.10. INPUT/OUTPUT
      11. 6.11. DATA STRUCTURES
      12. 6.12. MEMORY MANAGEMENT
      13. 6.13. THE PREPROCESSOR
      14. 6.14. ORGANIZING PROGRAMS
      15. 6.15. SUMMARY
    3. 7. The Objective-C Language
      1. 7.1. OBJECT-ORIENTED PROGRAMMING
      2. 7.2. CLASSES AND OBJECTS
      3. 7.3. METHODS
      4. 7.4. DATA HIDING
      5. 7.5. SUBCLASSING
      6. 7.6. MESSAGING
      7. 7.7. PROTOCOLS AND INFORMAL PROTOCOLS
      8. 7.8. NAMING CONVENTIONS
      9. 7.9. CREATING AND DESTROYING OBJECTS
      10. 7.10. MEMORY MANAGEMENT
      11. 7.11. ACCESSOR METHODS AND PROPERTIES
      12. 7.12. SUMMARY
    4. 8. Introduction to Cocoa
      1. 8.1. CONNECTING COCOA INTERFACES
        1. 8.1.1. Connecting Interfaces Manually with Outlets and Actions
        2. 8.1.2. Working with Cocoa Bindings
        3. 8.1.3. The Model/View/Controller Design Pattern
      2. 8.2. SUMMARY
    5. 9. Document-Based Cocoa Applications
      1. 9.1. WORKING WITH DOCUMENTS
        1. 9.1.1. Creating a New Document
      2. 9.2. SUBCLASSING CONTROLS IN INTERFACE BUILDER
      3. 9.3. CONNECTING MENUS
      4. 9.4. SUMMARY
    6. 10. Core Data-Based Cocoa Applications
      1. 10.1. ARCHIVING OBJECTIVE-C OBJECTS
      2. 10.2. MODELING OBJECTS WITH CORE DATA
      3. 10.3. CONNECTING USER INTERFACE TO CORE DATA
      4. 10.4. SELECTING FILES WITH OPEN PANELS
      5. 10.5. CREATING NEW DOCUMENTS
      6. 10.6. SORTING RESULTS
      7. 10.7. USING TRANSIENT OBJECTS
      8. 10.8. APPLICATION PREFERENCES
      9. 10.9. SUMMARY
  8. III. Script Programming
    1. 11. Overview of Scripting Languages
      1. 11.1. WHAT IS A SCRIPT?
      2. 11.2. WHAT IS A SCRIPTING LANGUAGE?
      3. 11.3. BASH
        1. 11.3.1. Why Bash?
        2. 11.3.2. More Information
      4. 11.4. APPLESCRIPT
        1. 11.4.1. Why AppleScript?
        2. 11.4.2. More Information
      5. 11.5. PYTHON
        1. 11.5.1. Why Python?
        2. 11.5.2. More Information
      6. 11.6. RUBY
        1. 11.6.1. Why Ruby?
        2. 11.6.2. More Information
      7. 11.7. JAVASCRIPT
        1. 11.7.1. Why JavaScript?
        2. 11.7.2. More Information
      8. 11.8. OTHER SCRIPTING LANGUAGES
      9. 11.9. SUMMARY
    2. 12. The Bash Shell
      1. 12.1. GETTING STARTED
        1. 12.1.1. The Command-Line Interface
        2. 12.1.2. Interactive versus Script
        3. 12.1.3. The Terminal Application
        4. 12.1.4. Editors
        5. 12.1.5. Configuring Bash
      2. 12.2. UNIX BASICS
        1. 12.2.1. Paths
        2. 12.2.2. Locating and Learning Commands
        3. 12.2.3. Running Commands and Other Executables
        4. 12.2.4. Redirecting Input and Output
        5. 12.2.5. Navigating the File System
        6. 12.2.6. Working with Files and Directories
        7. 12.2.7. File Permissions
        8. 12.2.8. Globbing
        9. 12.2.9. Searching for Files
        10. 12.2.10. Working with Text
        11. 12.2.11. Process Control
        12. 12.2.12. Mac OS X Exclusive Commands
        13. 12.2.13. Overview of Other Commands
      3. 12.3. SHELL PROGRAMMING
        1. 12.3.1. Scripts
        2. 12.3.2. Variables
        3. 12.3.3. Quoting
        4. 12.3.4. Conditional Branching
        5. 12.3.5. Looping
        6. 12.3.6. Functions
      4. 12.4. SUMMARY
    3. 13. AppleScript and AppleScriptObjC
      1. 13.1. APPLESCRIPT
        1. 13.1.1. Creating an AppleScript
        2. 13.1.2. Scriptable and Recordable Applications
        3. 13.1.3. Apple Events
        4. 13.1.4. Variables and Data Types
        5. 13.1.5. Handlers
        6. 13.1.6. Control Statements
          1. 13.1.6.1. Conditional Branching
          2. 13.1.6.2. Looping
          3. 13.1.6.3. tell Command
          4. 13.1.6.4. Punctuation
          5. 13.1.6.5. Exception Handling
        7. 13.1.7. Operators
          1. 13.1.7.1. Equality and Inequality Operators
          2. 13.1.7.2. The Concatenation Operator
          3. 13.1.7.3. The Contains Operator
        8. 13.1.8. Specifying Elements
        9. 13.1.9. Scripts and Objects
        10. 13.1.10. Classes
        11. 13.1.11. Working with Scripts
      2. 13.2. APPLESCRIPT APPLICATIONS
        1. 13.2.1. The AppleScriptObjC Bridge
        2. 13.2.2. Using Xcode
        3. 13.2.3. Using Interface Builder
      3. 13.3. SUMMARY
    4. 14. JavaScript, Dashboard, and Dashcode
      1. 14.1. JAVASCRIPT
        1. 14.1.1. Dashboard
      2. 14.2. DASHCODE
      3. 14.3. SUMMARY
  9. A. Answers to Exercises
    1. A.1. CHAPTER 1
      1. A.1.1. Exercise 1 Solution
      2. A.1.2. Exercise 2 Solution
    2. A.2. CHAPTER 2
      1. A.2.1. Exercise 1 Solution
      2. A.2.2. Exercise 2 Solution
    3. A.3. CHAPTER 3
      1. A.3.1. Exercise 1 Solution
      2. A.3.2. Exercise 2 Solution
      3. A.3.3. Exercise 3 Solution
    4. A.4. CHAPTER 4
      1. A.4.1. Exercise 1 Solution
      2. A.4.2. Exercise 2 Solution
    5. A.5. CHAPTER 5
      1. A.5.1. Exercise 1 Solution
      2. A.5.2. Exercise 2 Solution
    6. A.6. CHAPTER 6
      1. A.6.1. Exercise 1 Solution
      2. A.6.2. Exercise 2 Solution
    7. A.7. CHAPTER 7
      1. A.7.1. Exercise 1 Solution
      2. A.7.2. Exercise 2 Solution
    8. A.8. CHAPTER 8
      1. A.8.1. Exercise 1 Solution
      2. A.8.2. Exercise 2 Solution
    9. A.9. CHAPTER 9
      1. A.9.1. Exercise 1 Solution
      2. A.9.2. Exercise 2 Solution
    10. A.10. CHAPTER 10
      1. A.10.1. Exercise 1 Solution
      2. A.10.2. Exercise 2 Solution
      3. A.10.3. Exercise 3 Solution
    11. A.11. CHAPTER 11
      1. A.11.1. Exercise 1 Solution
      2. A.11.2. Exercise 2 Solution
      3. A.11.3. Exercise 3 Solution
    12. A.12. CHAPTER 12
      1. A.12.1. Exercise 1 Solution
      2. A.12.2. Exercise 2 Solution
    13. A.13. CHAPTER 13
      1. A.13.1. Exercise 1 Solution
      2. A.13.2. Exercise 2 Solution
      3. A.13.3. Exercise 3 Solution
    14. A.14. CHAPTER 14
      1. A.14.1. Exercise 1 Solution
      2. A.14.2. Exercise 2 Solution
  10. B. Developer Resources
    1. B.1. WEB SITES
    2. B.2. MAILING LISTS
    3. B.3. OTHER RESOURCES