On 26/05/2012, at 10:25 PM, Peter wrote:
> On the other hand I have never seen/never tried to call AppleScript from
> Cocoa in AppleScriptObjC terms - if this wording makes sense at all. I don't
> remember reading about this in your book, which focuses of course on
> accessing Cocoa from AppleScript.
It's not in the book, but it's pretty simple. You just need to stick to passing
objects of the main classes (NSString, NSArray, NSNumber, NSDictionary, NSData)
and coercing them in the receiving handler. So in this case you might have an
AS "class" with a handler like this:
on selectItemsInFinder_(arrayOfPaths)
set arrayOfPaths to arrayOfPaths as list -- coerce from pseudo-pointer
to AS object
set fileList to {}
repeat with aPath in arrayOfPaths
set end of fileList to aPath as POSIX file
end repeat
tell application "Finder" to select fileList
end selectItemsInFinder_
And you can call it as either a class or instance method:
NSArray *array = *paths*
[ASClassInstance selectItemsInFinder:array];
or:
[[ASClassName alloc] init] selectItemsInFinder:array];
or:
[ASClassName selectItemsInFinder:array];
--
Shane Stanley <[email protected]>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]