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

 Blog Topics
 
 Archive
 

15 Most Recent [RSS]

 Less work through Xcode and shell scripts
2011-12-16 @600
 
 iTunesCantComplain released
2011-10-28 @954
 
 Dennis Ritchie deceased
2011-10-13 @359
 
 Thank you, Steve.
2011-10-06 @374
 
 Cocoa Text System everywhere...
2011-03-27 @788
 
 Blog migration
2011-01-29 @520
 
 All you need to know about the Mac keyboard
2010-08-09 @488
 
 Review: Sherlock
2010-07-31 @978
 
 Playing with Objective C on Debian
2010-05-08 @456
 
 Fruit vs. Obst
2010-05-08 @439
 
 Mixed-language ambiguity
2010-04-15 @994
 
 Uli's 12:07 AM Law
2010-04-12 @881
 
 Uli's 1:24 AM Law
2010-04-12 @874
 
 Uli's 6:28 AM Law
2010-04-12 @869
 
 Uli's 3:57 PM Law
2010-04-12 @867
 

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
Or E-Mail Uli privately.

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