Cocoa Scripting Guide
PDF
Introduction
Overview of Cocoa Support for Scriptable Applications
AppleScript and Scriptable Applications
The AppleScript Object Model
Scriptability Information
Scriptability Information Formats
Viewing Scripting Terminology
Built-in Support for Standard and Text Suites
Built-in Support for Basic AppleScript Types
Loading Scriptability Information
Reliance on Key-Value Coding
Interaction With Cocoa Bindings and Core Data
Scriptability and Undo
Snapshot of Cocoa Scripting
A Real World Scripting Example
Current Limitations of Cocoa Scripting Support
Designing for Scriptability
Designing a New Scriptable Application
Adding Scriptability to an Existing Application
Implementing a Scriptable Application
Implementation Guidelines
Supply a Scripting Definition File
Concentrate Scriptable Behavior in Model Objects
Provide Keys for Key-Value Coding
Add the Scripting Definition File to Your Xcode Project
Turn On Scripting Support in Your Application
Implement Object Specifier Methods for Scriptable Classes
Use the Document Architecture
Access the Text Suite
Preparing a Scripting Definition File
Structure of a Scripting Definition File
Code Constants Used in Scriptability Information
Features Common to Many Scripting Definition File Elements
High-level XML Elements
XML Version and Document Type Definition
Dictionary Element
Suite Elements
Create a Scripting Definition File
Add Information to the Scripting Definition File
Class Elements
Property Elements
Element Elements
Contents Elements
Command Elements
Enumeration Elements
Record-Type Elements
Value-Type Elements
Cocoa Elements
Getting and Setting Properties and Elements
Overview of Getting and Setting Values
Key-Value Coding and Cocoa Scripting
Maintain KVC Compliance
On Omitting KVC Accessors
Performance Considerations With KVC
Interaction With Key-Value Observing
KVC Conversion of Scalar and Structure Values
Scripting Additions to KVC
Sample KVC-Compliant Accessor Methods
Single-Value Access
Collection Value Access
Special Accessor Methods
Support for the Properties Property
Coercion
Object Specifiers
Overview of Object Specifiers
Object Specifiers and KVC
When to Implement an Object Specifier Method
About Object Specifier Classes
A Closer Look at an Object Specifier
Evaluation of Nested Specifiers
Cocoa Object Specifier Classes
Implementing the Object Specifier Method
An Object Specifier Method for a Rectangle in Sketch
Specifying the Application Object as a Container
Implementing A Method for Evaluating Object Specifiers
Implicitly Specified Subcontainers
Script Commands
Script Commands Overview
Script Command Classes Supplied by Cocoa
Script Command Scriptability Information
Script Command Components
Script Command Creation
Script Command Execution
Script Commands and Object Specifiers
Error Handling
Object-first Versus Verb-first Script Commands
About Object-first Script Commands
About Verb-first Script Commands
Mixing Object-first and Verb-first Behavior
Steps for Implementing a New or Modified Script Command
Implementing an Object-First Command—Rotate
Implementing a Verb-First Command—Align
Modifying a Standard Command
A Verb-first Move Command
An Object-first Move Command
Summary of AppleScript Command Support
Testing, Debugging, and Performance
Scriptability Test Plan
Use AppleScript Scripts to Test Your Application
Turn On Debugging Output for Scripting
Steps for Turning On Cocoa Debugging Output
Sample Output
Debugging Scriptability Information
Checking an sdef File with xmllint
Examining Scriptability Information in Your Application
Additional Debugging Tips
Performance Issues for Scriptability
Cocoa Scripting Classes and Categories
Script Commands and Scriptability Information
Object Specifiers, Logical Tests, and Related Categories
Key-Value Coding and Value Coercion
Subclasses for Standard AppleScript Commands
Manipulation of Apple Events
How Cocoa Applications Handle Apple Events
Apple Event Handling Overview
Basics of Apple Event Handling
Handling Apple Events in a Cocoa Application
Nonscriptable Applications
Scriptable Applications
Apple Events Sent by the Mac OS
Open Application
Reopen
Open
Print
Open Contents
Quit
Constants for Apple Event Handlers Installed by the Application Kit
Installing an Apple Event Handler
Installing a Get URL Handler
Implementing the Get URL Handler
Suspending and Resuming Apple Events and Script Commands
Appendix A: Evolution of Cocoa Scriptability Information
Scriptability Terms
Changes in Scriptability Information Versions
Advantages of the Scripting Definition Format
Advantages of the Script Suite Format
Converting and Updating Scriptability Information
Creating Suite Files or 'aete' Files from a Scripting Definition
Creating Scripting Definitions from Suite Files or 'aete' Files
Updating Older Scripting Definition Files for Mac OS X Version 10.4
Editing Scriptability Information
Appendix B: Script Suite and Script Terminology Files
Script Suite Files
The Structure of a Script Suite File
Script Terminology Files
The Structure of a Script Terminology File
Cocoa Scripting’s Built-in Script Suites
Creating Your Own Script Suite Files
Revision History
Glossary
Related Reference
Objective-C
NSAppleEventDescriptor
NSAppleEventManager
NSAppleScript
NSClassDescription
NSCloneCommand
NSCloseCommand
NSComparisonMethods
NSCountCommand
NSCreateCommand
NSDeleteCommand
NSExistsCommand
NSGetCommand
NSIndexSpecifier
NSLogicalTest
NSMiddleSpecifier
NSMoveCommand
NSNameSpecifier
NSPositionalSpecifier
NSPropertySpecifier
NSQuitCommand
NSRandomSpecifier
NSRangeSpecifier
NSRelativeSpecifier
NSScriptClassDescription
NSScriptCoercionHandler
NSScriptCommand
NSScriptCommandDescription
NSScriptExecutionContext
NSScriptKeyValueCoding
NSScriptObjectSpecifier
NSScriptObjectSpecifiers
NSScriptSuiteRegistry
NSScriptWhoseTest
NSScriptingComparisonMethods
NSSetCommand
NSSpecifierTest
NSUniqueIDSpecifier
NSWhoseSpecifier
Related Documents
Key-Value Coding Programming Guide
Cocoa Fundamentals Guide