Re: Scripting Bridge usage, iPhoto example
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