• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Bridge question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Bridge question


  • Subject: Re: Scripting Bridge question
  • From: has <email@hidden>
  • Date: Thu, 15 Nov 2007 20:46:44 +0000

Andrew Kimpton wrote:

When I first started using ScriptingBridge I struggled with a similar problem (iTunes add: wants an NSArray - an array of what ? It turns out it needs an array of NSURL's).

Actually, the iTunes dictionary specifies a list of aliases (typeAlias) for the 'add' command, but as long as the command is well- implemented (i.e. asks the Apple Event Manager to coerce the supplied values to the desired type) it should be able to accept file URLs (typeFileURL) as well. Cocoa doesn't provide an equivalent to Carbon's Alias type, and Scripting Bridge doesn't define an equivalent class itself, so I'm assuming it just uses NSURLs in both cases.



To debug this I ran the Script Editor app 'in debug mode' with a small
handwritten script to mirror my action. To do this set the AEDebugSend
environment variable in a Terminal window and then launch the script
editor app from the same terminal session. ScriptEditor will log to
stdout a dump of the raw events it was sending to iTunes - I could see
that my posix path was being converted to an 'furl' applevent and from
their I deduced the NSURL requirement.

Crap documentation tools is certainly one of Scripting Bridge's various shortcomings. Unfortunately, Apple haven't published the rules by which Scripting Bridge translates AppleScript-style keywords and Apple event types to their ObjC equivalents, otherwise I could add a 'Scripting Bridge' option to ASDictionary [1] which can already export very nice HTML-based application dictionaries for AppleScript and Python/Ruby/ObjC-appscript.


However, you shouldn't need to resort to AEDebug to determine type info (except perhaps as a last resort): if you look at the application's dictionary in Script Editor/Smile/Script Debugger/ ASDictionary, you can probably guess the desired Cocoa class based on the AppleScript type shown - e.g. 'list of Unicode text' would be an NSArray of NSStrings; 'list of integer' would presumably be an NSArray of NSNumbers; etc.

You might also want to file a feature request asking that sdp- generated headers add a full type description to the comments of properties and parameters, e.g.:

- (itunesTrack *) add:(NSArray *)/*of NSURL*/ x to:(SBObject *)to; // add one or more files to a playlist

(Incidentally, while on the topic of SB sins, be warned that iTunes' 'add' command will return either a reference OR a list of references, depending on the number of files you give it. Unfortunately, the iTunes dictionary is somewhat imprecise in describing the return type, so the above sdp-generated declaration ends up with the wrong result type.)

has

[1] http://appscript.sourceforge.net/download.html
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Scripting Bridge question
  • Next by Date: Re: Weird problem with writeToUrl:ofType:error
  • Previous by thread: Re: Scripting Bridge question
  • Next by thread: How to get x-coordinate?
  • Index(es):
    • Date
    • Thread