Re: AppleScript in 10.9
Re: AppleScript in 10.9
- Subject: Re: AppleScript in 10.9
- From: Shane Stanley <email@hidden>
- Date: Wed, 23 Oct 2013 11:29:52 +1100
On 23 Oct 2013, at 11:18 AM, Alex Hall <email@hidden> wrote:
> So, if I'm reading this right, we can use ObjC in AS files, or at least call ObjC library functions? Did I seriously just read that?
Yes, you read that right. Here's a simple example. In AppleScript Editor, enter this:
use framework "Foundation"
on sortAList:aList
set anArray to current application's NSArray's arrayWithArray:aList
return (anArray's sortedArrayUsingSelector:"compare:") as list
end sortAList:
Save it as a .scptd file to ~/Library/Script Libraries/ (you will have to create the folder). Then click on the Bundle Contents button in the script window's toolbar, and check next to AppleScript/Objective-C Library. Save.
Now open another script window and then enter this, changing the name to that of the library you just saved (minus the extension):
use theLib : script "<script name here>"
set theResult to theLib's sortAList:{2, 8, 3, 9, 4, 0, 1}
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden