Re: jumpstart me with the scripting bridge
Subject : Re: jumpstart me with the scripting bridge
From: has <email@hidden >
Date: Fri, 9 Nov 2007 23:43:50 +0000
Delivered-to: email@hidden
Delivered-to: email@hidden
On 8 Nov 2007, at 20:25, has wrote:
So it looks as if Apple already knew that -addObject:'s approach was
defective because it broke on *Finder*, no less, and had to hardcode
a special, Finder-specific exception into Scripting Bridge to avoid
embarrassing themselves.
Addendum to the addendum: looks as if iTunes wasn't as blessed:
import ScriptingBridge as sb
itunes =
sb.SBApplication.applicationWithBundleIdentifier_(u'com.apple.itunes')
playlists = itunes.sources().objectAtIndex_(0).playlists()
newplaylist =
itunes
.classForScriptingClass_
(u'playlist').alloc().initWithProperties_({u'name': u'my playlist'})
playlists.addObject_(newplaylist)
throws:
File "/tmp/tmpscript", line 26, in <module>
playlists.addObject_(newplaylist)
objc.error: NSGenericException - Apple event returned an error.
Event = 'core'\'crel'{ 'kocl':'cPly', 'insh':'insl'{ 'kobj':'obj
'{ 'want':'cPly', 'from':'obj '{ 'want':'cSrc', 'from':'null'(),
'form':'indx', 'seld':1 }, 'form':'indx', 'seld':'abso'($206C6C61$) },
'kpos':'end ' }, 'prdt':{ 'pnam':'utxt'("my playlist") } }
Error info = {
ErrorNumber = -10014;
}
The correct form - as iTunes scripters will know - is:
app
('iTunes
').make
(:new=>:playlist, :at=>app.sources[1], :with_properties=>{:name=>'my
playlist'})
and you can omit the 'at' parameter if you want, e.g.:
ITApplication *itunes = [[ITApplication alloc] initWithName:
@"iTunes.app"];
NSDictionary *properties = [NSDictionary dictionaryWithObject:@"my
playlist" forKey:[ASConstant name]];
ITMakeCommand *cmd = [[[itunes make] new_: [ITConstant playlist]]
withProperties: properties];
ITReference *playlist = [cmd send];
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.