• 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: Scripting Bridge usage, iPhoto example
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Bridge usage, iPhoto example


  • Subject: Re: Scripting Bridge usage, iPhoto example
  • From: has <email@hidden>
  • Date: Thu, 13 May 2010 19:45:13 +0100

Jeffrey J. Early wrote:

> I'm having some difficulties mapping commands from from an AppleScript script to ScriptingBridge and was hoping someone might be able to point me in the right direction.
>
> As a reduced example/test case, I have the following script to set the rating and assign a keyword to the selected photo in iPhoto,
>
> tell application "iPhoto"
> 	set selectedPhotos to the selection
> 	repeat with thisPhoto in selectedPhotos
> 		set rating of thisPhoto to 2
> 		assign keyword string "Vacation"
> 	end repeat
> end tell
>
> As  long as "Vacation" is an existing keyword, this script works just fine. Trying (what I think should be) the equivalent ScriptingBridge,
>
> iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"];
> for (iPhotoPhoto *photo in [iPhoto selection]) {
> 	[photo setRating: 3];
> 	[photo assignKeywordString: @"Vacation"];
> }

These are not equivalent. To match your AppleScript, your last line should read [1]:

	[iPhoto assignKeywordString: @"Vacation"];

However, I expect this will break due to a bug in SB:

	http://stackoverflow.com/questions/2802596/creating-iphoto-albums-using-cocoa-scripting-bridge

Also, obligatory self-plug:

	http://appscript.sourceforge.net/objc-appscript

More capable, less obfuscated, much less prone to application compatibility problems, better documentation, dev tools and support, etc.

HTH

has

[1] Also, since 'assign keyword' acts on the current selection, there's no need for it to be inside the loop (which is a bit misleading to the casual reader).

--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

 _______________________________________________
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

  • Follow-Ups:
    • Re: Scripting Bridge usage, iPhoto example
      • From: "Jeffrey J. Early" <email@hidden>
  • Prev by Date: Re: Scripting Help Viewer?
  • Next by Date: Re: Scripting Help Viewer?
  • Previous by thread: Re: Scripting Bridge usage, iPhoto example
  • Next by thread: Re: Scripting Bridge usage, iPhoto example
  • Index(es):
    • Date
    • Thread