do shell script
and access to shell commands — it can also involve a significant learning curve.«class ocid» id «data optr00000000C0E0017AFF7F0000»
That’s not particularly illuminating.«class ocid»..
, you will see much more. Here is a simple script to get the name of all the files on your desktop in an array:«class ocid» id «data optr00000000C0E0017AFF7F0000»
.description
method, to give some idea of what it contains. If you have ever used the NSLog()
function, which can be used to print a description to the Console, you may notice that what Script Debugger is showing for the sample script doesn’t match the Objective-C formatting. For classes that have an AppleScript equivalent or near-equivalent, like NSArray here, Script Debugger will reformat the description into a more AppleScript-like form.«class ocid»..
, but it gets better. Click on Best instead of Desc/Source. Script Debugger will now display an explorer view of the contents of the array, similarly to how it would if it were an AppleScript list.theFiles
listed, and if you click on the disclosure triangle next to it, the contents of the array are again displayed. <NSFileManager: 0x608000000060>
. This is the normal description of the file manager (the number reflects its address in memory). Step again and you can swap between Best and Desc to switch between the description and explorer views.NSS
or nss
, and get the same result; the correct case will be inserted. You can also use the tab key within the completion list; this is very helpful where there are multiple methods with similar names. How this works is described in Script Debugger’s Help.use framework
statement. So if you are scripting the AppKit framework, your use framework 'AppKit'
statement will also load its terminology for code completion. And you need to compile your script after adding a new use framework
statement to make the framework’s terminology available.use AppleScript version..
statement in your script, methods and classes introduced in versions of the system released after the specified version of AppleScript will not appear in completion lists. Because new Objective-C classes and methods are regularly added to the OS as new versions are released, this is an important way you can avoid accidentally including code that will not run under the version of the OS you are targeting.x's y
over y of x
.error
. When you enter such a method using code completion, the placeholder for these parameters will contain the text missingValueOrReference
. This is because you can only provide one of two values: (missing value)
if you are not interested in the value, or reference
if you want the value to be returned along with the result of the method. In such cases, when you select the placeholder, usually by tabbing to it, you can type esc or return, and a popup menu will appear showing the two values, (missing value) and reference, and you can select which to insert.trueOrFalse
.current application's
in-line where needed, or by automatically declaring properties for Cocoa terms. This is controlled by the checkbox in Preferences -> Editor labelled Use properties for Cocoa terms in completion, clippings. You can also set it on a document-by-document basis by checking or unchecking the menu item Edit -> AppleScriptObjC -> Use Properties for Cocoa Terms.a reference to 4
rather than simply 4
relates to one of the other new Script Debugger features: the ability to change existing code from one form of referencing current application to the other.current application's
inserted inline for any declared Cocoa terms.performSelectorOnMainThread:withObject:waitUntilDone:
to do it. If not, you are likely to freeze or crash Script Debugger.current application
will be done in the same way is it would using code completion.