• 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: Sending a list of path strings to the Finder via Scripting Bridge
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending a list of path strings to the Finder via Scripting Bridge


  • Subject: Re: Sending a list of path strings to the Finder via Scripting Bridge
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 26 May 2012 22:58:45 +1000

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@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>


_______________________________________________

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

  • Follow-Ups:
    • Re: Sending a list of path strings to the Finder via Scripting Bridge
      • From: Peter <email@hidden>
References: 
 >Sending a list of path strings to the Finder via Scripting Bridge (From: Peter <email@hidden>)
 >Re: Sending a list of path strings to the Finder via Scripting Bridge (From: Shane Stanley <email@hidden>)
 >Re: Sending a list of path strings to the Finder via Scripting Bridge (From: Peter <email@hidden>)
 >Re: Sending a list of path strings to the Finder via Scripting Bridge (From: Peter <email@hidden>)
 >Re: Sending a list of path strings to the Finder via Scripting Bridge (From: Shane Stanley <email@hidden>)
 >Re: Sending a list of path strings to the Finder via Scripting Bridge (From: Peter <email@hidden>)

  • Prev by Date: Re: Sending a list of path strings to the Finder via Scripting Bridge
  • Next by Date: Re: Sending a list of path strings to the Finder via Scripting Bridge
  • Previous by thread: Re: Sending a list of path strings to the Finder via Scripting Bridge
  • Next by thread: Re: Sending a list of path strings to the Finder via Scripting Bridge
  • Index(es):
    • Date
    • Thread