O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MacRuby: The Definitive Guide

Book Description

Want to build native Mac OS X applications with a sleek, developer-friendly alternative to Objective-C? MacRuby is an ideal choice. This in-depth guide shows you how Apple’s implementation of Ruby gives you access to all the features available to Objective-C programmers. You’ll get clear, detailed explanations of MacRuby, including quick programming techniques such as prototyping.

Perfect for programmers at any level, this book is packed with code samples and complete project examples. If you use Ruby, you can tap your skills to take advantage of Interface Builder, Cocoa libraries, the Objective-C runtime, and more. If you’re a Cocoa developer, you’ll learn how to improve your productivity with MacRuby.

  • Get up to speed on MacRuby basics, including classes and methods
  • Learn how to use MacRuby with Apple’s Xcode developer suite
  • Delve into the primitive object classes and data types in Foundation Kit
  • Build event-driven user interfaces with the AppKit framework
  • Handle relational object persistence with the Core Data framework
  • Use advanced MacRuby techniques, including concurrency and sandboxing
  • Get examples for applications using Twitter and a location web service
  • Embed MacRuby into existing Objective-C applications

Table of Contents

  1. MacRuby: The Definitive Guide
  2. Dedication
  3. Preface
    1. The Purpose of This Book
    2. Prerequisites
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  4. I. MacRuby Overview
    1. 1. Introduction
      1. Introducing MacRuby
        1. Why MacRuby?
      2. Installation
        1. Mac OS X
        2. Xcode
        3. MacRuby
      3. Code Example
      4. Loading a Framework
      5. Using Classes
        1. Defining a Class and Its Methods
        2. Ruby Class Instantiation
      6. Methods
        1. Documentation
          1. Method prototypes
          2. Constant names
        2. The Interactive Ruby Shell
        3. Syntactic Sugar
    2. 2. Fundamentals
      1. Run Loops
      2. Callbacks/Delegation
      3. User Inputs
      4. Outlets
      5. Display
      6. Example
    3. 3. The Cocoa Environment
      1. History
      2. Main Frameworks in the Cocoa API
        1. Foundation Framework
        2. AppKit Framework
        3. CoreData Framework
      3. Reference Library
        1. Central Panel
        2. Sidebar
      4. Mutability
    4. 4. Foundation
      1. Compatibility Table
      2. Strings and Attributed Strings
      3. Arrays
      4. Hashes/Dictionaries
      5. Sets
      6. Enumerators
      7. Date, Time, and Calendars
        1. NSDate
        2. NSCalendar
      8. Data
      9. Locales
      10. Time Zones
      11. Exceptions
      12. I/O
      13. URLs/Requests/Connections
        1. Cache Policy and Cache Access
        2. Asynchronous Versus Synchronous
      14. Pipes
      15. File Handles
      16. Bundles
      17. Scheduling
        1. Run Loops
        2. Timers
        3. Tasks/Subprocesses
        4. Threads
        5. Operations/Operation Queues
      18. Notifications
        1. Notification Centers
        2. Notification Queues
      19. Archiving and Serialization
      20. Miscellaneous Classes
        1. XML Parsing
        2. Filtering/Logical Conditions
        3. Undo/Redo
        4. User’s Preferences
    5. 5. Application Kit
      1. Cocoa Key Principles
        1. Model-View-Controller Design Pattern
        2. Protocols
        3. Key-Value Coding
        4. Bindings
        5. Delegation
      2. User Interface
        1. Windows, Views, and Cells
          1. Windows and panels
          2. Views
          3. Cells
        2. Positioning
        3. Events and the Responder Chain
        4. Drawing
        5. Graphics Context
        6. Images
    6. 6. Xcode
      1. Xcode IDE
        1. Template
        2. Navigator Area
        3. Editor Area
        4. Debug Area
        5. Utility Area
    7. 7. Core Data
      1. Data Model
        1. The Data Model and the Entity
        2. Adding Attributes
        3. Relationships
        4. Setting Up Controllers
      2. User Interface
        1. Movies
        2. Art Cover
        3. Actors
        4. Search
      3. Persistence
        1. Managed Object Model
        2. Managed Object Context
        3. Persistent Store Coordinator
        4. Workflow
    8. 8. One Step Deeper
      1. Selectors
      2. Blocks
      3. Concurrency
        1. Grand Central Dispatch
          1. Queues
          2. Groups
          3. GCD dispatch gem
      4. Sandboxing
      5. Using Objective-C or C Code
      6. Scriptable Applications
      7. Method Missing
      8. Pointers
        1. Void Pointers
        2. Unsigned Pointer
      9. Compilation
      10. Compilation Within Xcode
  5. II. MacRuby in Practice
    1. 9. Address Book Example
      1. User Interface
      2. Address Book
      3. Web API Call
      4. Cleaning Up: Better Management of Widgets
      5. The Extra Mile: Displaying More Information Through Notifications
    2. 10. Geolocation
      1. User Interface
      2. Table View
      3. Core Location
      4. Web API
    3. 11. MacRuby in Objective-C Projects
      1. API
      2. Usage
      3. Example in an Xcode Project
        1. User Interface
        2. Using the MacRuby Method
    4. 12. Objective-C Code in MacRuby Apps
      1. Dynamic Library
      2. Framework
        1. BridgeSupport
    5. 13. Using Ruby Third-Party Libraries
      1. RubyGems
      2. MacRuby Deploy
  6. Index
  7. About the Author
  8. Colophon
  9. Copyright