Programming Cocoa with Ruby Create Compelling Mac Apps Using RubyCocoa



Similar documents
Appendix A How to create a data-sharing lab

Chapter 1. Introduction to ios Development. Objectives: Touch on the history of ios and the devices that support this operating system.

Kevin Hoffman. Sams Teach Yourself. Mac OS* X Lion" App Development. 800 East 96th Street, Indianapolis, Indiana, USA

View Controller Programming Guide for ios

NSPersistentDocument Core Data Tutorial for Mac OS X v10.4. (Retired Document)

NASA Workflow Tool. User Guide. September 29, 2010

MA-WA1920: Enterprise iphone and ipad Programming

Xcode Project Management Guide. (Legacy)

Chapter 1. Xcode Projects

Your First App Store Submission

An Introduction to Modern Software Development Tools Creating A Simple GUI-Based Tool Appleʼs XCode Version 3.2.6

Video on Online Archives and how to use them:

Introduction to iphone Development

Personal Portfolios on Blackboard

USER GUIDE. Unit 2: Synergy. Chapter 2: Using Schoolwires Synergy

Project Builder for Java. (Legacy)

2. About iphone ios 5 Development Essentials. 5. Joining the Apple ios Developer Program

What's it Called on my Mac?

Process Document Campus Community: Create Communication Template. Document Generation Date 7/8/2009 Last Changed by Status

Database Forms and Reports Tutorial

Agile Web Development with Rails 4

How to Change Your Schedule for Holidays

Version Control with Subversion and Xcode

EMC Documentum Composer

Mobile App Design and Development

The Cucumber Book. Extracted from: Behaviour-Driven Development for Testers and Developers. The Pragmatic Bookshelf

Code::Blocks Student Manual

Creating Carbon Menus. (Legacy)

How to install and use the File Sharing Outlook Plugin

Using FileMaker Pro with Microsoft Office

The tool also provides an overview of date criteria set against all items within your module.

INTRODUCTION TO IOS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 13 02/22/2011

DEPLOYING A VISUAL BASIC.NET APPLICATION

Introduction to Microsoft Access 2003

Tutorial: BlackBerry Object API Application Development. Sybase Unwired Platform 2.2 SP04

1.5 MONITOR. Schools Accountancy Team INTRODUCTION

XenMobile Logs Collection Guide

Lab 2-2: Exploring Threads

MY WORLD GIS. Installation Instructions

Bonita Open Solution. Introduction Tutorial. Version 5.7. Application Development User Guidance Profile: Application Developer

Overview... 2 How to Add New Documents... 3 Adding a Note / SMS or Phone Message... 3 Adding a New Letter How to Create Letter Templates...

A product of Byte Works, Inc. Credits Programming Mike Westerfield. Art Karen Bennett. Documentation Mike Westerfield

Learning ios Programming

Chapter 20: Workflow

NetBeans IDE Field Guide

MICROSOFT OFFICE ACCESS NEW FEATURES

Eclipse with Mac OSX Getting Started Selecting Your Workspace. Creating a Project.

Teradata SQL Assistant Version 13.0 (.Net) Enhancements and Differences. Mike Dempsey

How To Develop An App For Ios (Windows)

BillQuick Agent 2010 Getting Started Guide

FORM SIMPLICITY QUICK REFERENCE GUIDE PROFESSIONAL/ULTIMATE EDITION

Set up My Sites (SharePoint Server

Exploiting Key Answers from Your Data Warehouse Using SAS Enterprise Reporter Software

for Sage 100 ERP Business Insights Overview Document

Web UTAS. Common problems and solutions. Common problems with Java settings. Ensuring that you have the correct Java settings in place

Data Tool Platform SQL Development Tools

Chapter 15: Forms. User Guide. 1 P a g e

Xerox 700 Digital Color Press with Integrated Fiery Color Server. Printing from Mac OS

Kaspersky Password Manager

GX/GP Firmware Upgrade Procedure

MEAP Edition Manning Early Access Program Hello! ios Development version 14

ADOBE DRIVE CC USER GUIDE

ReviewSnap Quick Training Reference Creating a Self-Review

Application Programming on the Mac COSC346

CDOT Monumentation Sheets

SAP" Interactive Forms by Adobe*

Appendix F: Instructions for Downloading Microsoft Access Runtime

Content Management Implementation Guide 5.3 SP1

Create a new investment form and publish it to a SharePoint 2013 forms library

Book 1 Diving Into ios 7

SIMIAN systems. Sitellite Desktop User Manual. Sitellite Professional Edition

Editing your Website User Guide

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

WESSL-2 Script Builder Reference Guide

SAS BI Dashboard 4.3. User's Guide. SAS Documentation

Tutorial: BlackBerry Application Development. Sybase Unwired Platform 2.0

Primavera P6 Professional Windows 8 Installation Instructions. Primavera P6. Installation Instructions. For Windows 8 Users

MAKE A NEW SUBSITE 1. On the left navigation, click Site Contents (or Sites). Scroll down to subsites. Click new subsite.

Expat Tracker. User Manual HR Systems Limited

PTC Integrity Eclipse and IBM Rational Development Platform Guide

Troubleshooting problems with the PDMWorks Enterprise database server

Building a Python Plugin

Xerox 700 Digital Color Press with Integrated Fiery Color Server. Utilities

KeePass Getting Started on Windows

Mitigation Planning Portal MPP Reporting System

Adobe Acrobat: Creating Interactive Forms

eggon SDK for ios 7 Integration Instructions

Set up Delegate & Travelers

Table of Contents. Adding Build Targets to the SDK 8 The Android Developer Tools (ADT) Plug-in for Eclipse 9

Before You Begin: NOTE: Please read each step of these instructions carefully as not all steps include accompanying pictures.

User Guide Release Management for Visual Studio 2013

RoR to RubyMotion Writing Your First ios App With RubyMotion. Michael Denomy BostonMotion User Group June 25, 2013

Lab 0 (Setting up your Development Environment) Week 1

AvePoint Meetings for SharePoint Online. Configuration Guide

Exchange Granular Restore. User Guide

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Installation Assistance Windows/Microsoft Updates Updating from Spectra or Upgrading from Spectra 6.x...

App Distribution Guide

Transcription:

Programming Cocoa with Ruby Create Compelling Mac Apps Using RubyCocoa Brian Mariek The Pragmatic Bookshelf Raleigh. North Carolina Dallas. Texas

1 Introduction 1 1.1 What Is Cocoa? 2 1.2 What Is RubyCocoa? 2 1.3 What's It Like to Learn Cocoa Using Ruby? 2 1.4 RubyCocoa? That's So Last Year! 3 1.5 Prerequisites 3 1.6 Versions 5 1.7 Our Example App 6 1.8 Centuries of the Bookmaker's Art: Scorned 8 1.9 Some Terminology 9 1.10 Service After the Sale 9 1.11 Solving Problems 9 1.12 Acknowledgments 10 2 How Do We Get This Thing Started? 13 2.1 A Program That Prints 14 2.2 Putting an Item in the Status Bar 17 2.3 Menus 18 2.4 An Application Bundle 22 2.5 What Now? 26 I A First Realistic App 27 3 Working with Interface Builder and Xcode 29 3.1 The Basics 30 3.2 Creating and Editing Classes in Xcode 40 3.3 Debugging 47 3.4 Synchronizing Interface Builder and Xcode 49 3.5 Attributes 50 3.6 Overriding Window Behavior with a Delegate 52

vlii CONTENTS 3.7 Tiy This Yourself 53 3.8 What Now? 53 4 One Good App Observes Another 55 4.1 Notifications Within an App 55 4.2 Notifications Between Apps 60 4.3 The App to Fenestrate 63 4.4 Putting Notification Handling Behind the GUI 64 4.5 Reopening Objective-C Classes 66 4.6 What Now? 66 II Reshaping Fenestra 69 5 A Better GUI 71 5.1 Toggle Buttons 72 5.2 The Default Button 73 5.3 Combo Box Items 74 5.4 The Initial First Responder 75 5.5 Try This Yourself 75 5.6 What Now? 76 6 Decoupled Controllers 77 6.1 Ignorant Objects 78 6.2 Extracting Subclasses 80 6.3 Reacting to Button State 85 6.4 Using Nibs to Avoid Dependencies 85 6.5 Initializing Combo Boxes 87 6.6 What Now? 88 7 Notifications Connect Decoupled Objects 89 7.1 Controllers 89 7.2 Translators and the Rising Tide of Ugliness 91 7.3 What Now? 94 8 More Expressive Code 95 8.1 A DSL for Notifications 96 8.2 RubyCocoa Has Two Ways of Referring to Superclasses 98 8.3 Shorthand for Posting Notifications 98 8.4 Try This Yourself 100 8.5 What Now? 102

III Project Mechanics 103 9 Bundling Gems and Libraries with Your App 105 9.1 Manual Control 106 9.2 Standaloneify 110 9.3 What Now? 112 10 Project Organization, Builds, and Your Favorite Editor 113 10.1 Groups 114 10.2 Using Xcode with Hierarchical Project Folders 115 10.3 Running in Place 117 10.4 Building Without Xcode 117 10.5 Using Interface Builder with Hierarchical Project Folders 119 10.6 Starting a New Project 120 10.7 What Now? 121 IV Declarative Data Handling 123 11 Persistent User Preferences 125 11.1 The User Preferences System 126 11.2 Storing Custom Objects as Preferences 129 11.3 Using Archived Objects 137 11.4 Views Can Pull Data 141 11.5 Try This Yourself: A Sticky Window 143 11.6 What Now? 147 12 Creating a Preference Panel in a New Nib 149 12.1 Creating a Nib 150 12.2 Drawing the Panel 152 12.3 Hooking the Panel to the App 154 12.4 The Nib File's Owner 157 12.5 IB's First Responder Pseudo-Object 158 12.6 Memory Leaks 159 12.7 What Now? 160 13 Implementing a Preference Panel with Cocoa Bindings 161 13.1 Binding a Simple Value 161 13.2 Binding an Array of Hashes 165 13.3 Formatters 171 13.4 Value Transformers 176

x CONTENTS 13.5 Adding and Deleting Table Rows 181 13.6 What Now? 183 14 Setting Up Bindings with Code 185 14.1 Oh No! Terminology! 185 14.2 Using Rooted Keypaths in Code 189 14.3 Subclassing NSArrayController 189 14.4 bind_toobject_withkeypath_options 192 14.5 What Now? 196 V Fun with Tables 197 15 Prologue: Folders and Tests 199 15.1 Disk Layout 199 16 Selections and Editing 203 16.1 An Example of Creating Tests: The Add Method... 203 16.2 Working with an Uncooperative Control 213 16.3 Try This Yourself 221 16.4 Building Setup Methods 228 16.5 What Now? 230 17 Buttons in Tables 231 17.1 Cells 231 17.2 Making the Change 232 17.3 What Now? 234 18 A Formatter with Two Wrinkles 235 18.1 The Formatter Code 236 18.2 Calling Methods That Take Reference Arguments... 238 18.3 Breaking Encapsulation in Tests 241 18.4 What Now? 243 19 Picking Files with Open Panels 245 19.1 NSOpenPanel 245 19.2 A Design for Using NSOpenPanel in Fenestra 248 19.3 Try This Yourself: PreferencesController Tests 250 19.4 Try This Yourself: The NSOpenPanel Controller... 258 19.5 What Now? 260

20 Drag and Drop 263 20.1 How Drag and Drop Works 263 20.2 Designing the GUI 265 20.3 A Template for the Solution 266 20.4 Utility Classes and Modules 267 20.5 Try This Yourself: Lively Dragging Info 270 20.6 Try This Yourself: Drag and Drop 277 20.7 Does It Work? 282 20.8 What Now? 283 21 Epilogue: A Wonderful World of Tests 285 21.1 Test-Driven Design 285 21.2 To Learn More 288 VI Wrapping Up 289 22 Fit and Finish 291 22.1 Saving the Window Position Until the Next Launch.. 291 22.2 Tab Behavior 292 22.3 Using NSMatrix to Organize Buttons 293 22.4 Sizing 297 22.5 Cleaning Up the Menu Bar 301 22.6 The About Window 301 22.7 Changing the Application's Name 303 23 Adding Help 305 23.1 Help Book Basics 305 23.2 Creating a Help Book 306 23.3 Editing Pages 307 23.4 Hooking a Help Book into an App 313 23.5 A Workflow for Creating Help Book Pages 315 23.6 Tooltips 315 24 Document-Based Applications 317 24.1 The Major Players 318 24.2 The Responder Chain 320 24.3 Creating a New Document 323 24.4 Opening and Saving Documents 332 24.5 Editing 334 24.6 Learning More 337

xli CONTENTS 25 MacRuby 339 25.1 Getting MacRuby 342 25.2 MacRuby Basics 342 25.3 A MacRuby Checklist 344 25.4 What Now? 348 VII Reference 349 26 The Objective-C Bridge and Bridge Metadata 351 26.1 An Unexpected Return Value 351 26.2 What Information Can Be Found at Runtime? 352 26.3 Supplementing Runtime Information 353 26.4 Our Own Private Metadata 354 26.5 Finding Out More 355 27 The Underpinnings of Cocoa Bindings 357 27.1 Requirements 357 27.2 Our Goal 358 27.3 Declaring Observed Properties 359 27.4 Observing Changes 360 27.5 Implementing bind_toobject_withkeypath_options.. 362 27.6 Changing the Value of an Observed Key 363 27.7 In Summary 364 27.8 Postscript: Observing Changes to Collections 366 A Glossary 369 B Bibliography 381 Index 385