Uli's Web Site
[ Zathras.de - Uli's Web Site ]
Other Sites: Stories
Pix
Abi 2000
Stargate: Resurgence
Lost? Site Map!
 
 
     home | articles | moose | programming | articles >> blog

 Blog
 
 Blog Topics
 
 Archive
 

15 Most Recent [RSS]

 Uli's source code is on Github!
2010-03-05 @986
 
 Downtime on Friday
2010-03-04 @025
 
 Hacking the Press - A point for usability in press kits
2010-02-18 @404
 
 So. Git.
2010-02-15 @498
 
 Helpful Xcode User Scripts
2010-02-14 @485
 
 CocoaHeads München: Xcode Tiefergelegt Folien
2010-02-10 @995
 
 Debugging Assembler on Mac OS X
2010-02-07 @600
 
 The iPad
2010-01-29 @417
 
 Double click is a shortcut
2010-01-16 @621
 
 Removing transparency from NSImage
2010-01-16 @581
 
 Garbage collection, work of the devil?
2009-12-20 @881
 
 Let's talk about Coding Style
2009-12-15 @459
 
 The iPhone Reality Show
2009-12-13 @589
 
 The Sinus Curve of Life
2009-11-26 @430
 
 AppleScripting Cocoa a little
2009-11-26 @003
 

More...

AppleScripting Cocoa a little

So, you want to make your Cocoa application scriptable? You have a complex object model? You read Apple's excellent documentation, but need code to fill in some blanks? You can't find your way in Apple's sample code? Well, here's a few spots I found really helpful:

  • Matt Neuburg's Getting started with Cocoa Scripting A wonderful walkthrough on how to get started, how to get the application to ask your delegate for some AppleScript properties exposed through AppleScript's application object, and to expose custom objects as AppleScript classes, and provides lots of sample code snippets.
  • Apple's SimpleScriptingObjects Sample Code Shows how to use XInclude to get the standard suites, and also shows how to do more complex object hierarchies in a complete, working application.
  • Apple's ScriptingDefinitions Sample Code Not really sample code, but that's what they filed it under. It's two example scripting definitions that you can base your app's on.

A few notes that might help you:

  • The -objectSpecifier method is very important on your objects. Object specifiers are the only things that actually end up outside your app. If you don't provide that method for your objects, nothing will work.
  • Since Object Specifiers are the only thing that ends up outside your app, you can create temporary, different objects as stand-ins for objects in your app. You can expose a group of objects as one nice object to AppleScript users.
  • If you get the errAEBadKeyForm error, "bad key form" -10002, check whether any other dictionary defines the same property name as you do. AppleScript expects a one-to-one mapping of one string (e.g. "name") to one Four-character-code (e.g. 'pnam'), across all Applications' dictionaries. This also includes AppleScript's built-in identifiers. So be sure you use Apple's identifiers.

Reader Comments: (RSS Feed)
No comments yet
Comment on this article:
Name:
E-Mail: (not shown, hashed for Gravatar)
Web Site URL: (optional)
Comment: (plain text only)
Please Enter the following word:
Or E-Mail Uli privately.

 
Created: 2009-11-25 @975 Last change: 2009-11-26 @003 | Home | Admin | Edit
© Copyright 2003-2010 by M. Uli Kusterer, all rights reserved.