In former OS X versions (pre 10.6) it was possible to call Cocoa methods via the "call method" command in applescript ("Applescript Studio").
E开发者_开发知识库.g. this way:
set theURL to "http://www.apple.com"
set URLWithString to (call method "stringByAddingPercentEscapesUsingEncoding:" of theURL with parameter 30)
The script interpreter in the "Applescript Editor" (10.6) does not understand the command "call method". - Is there an equivalent for "Applescript Editor" (10.6)?
You can use "call method" in applescript. Apple gave that ability to Automator and we can access that ability from applescript by using the "Automator Runner" application. I just showed this to someone recently. See my post #4 here.
So to answer your question, just put your "call method" code inside a tell application "Automator Runner" tell block.
AppleScript Studio I thought was done in Xcode not AppleScript Editor. Code in AppleScript Editor can only be saved as scripts and the language is just plain AppleScript.
If you're doing this is Xcode, on 10.6, AppleScript Studio no longer exists. It's now AppleScript-Obj-C
I don't know an exact answer.. but...
If you take - (void)makeKeyAndOrderFront:(id)sender
in AppleScript-Obj-C, if I have a property linked to a window in Xcode I just go: myWindowProperty's makeKeyAndOrderFront_(sender)
I hope this helped at least a bit!
精彩评论