Skip navigation.
 
mlRe: Adding playlists to iTunes with SB
FROM : has
DATE : Sat Nov 24 16:03:18 2007

Eddy Hatcher wrote:

> I am trying to create a playlist and add it to iTunes using scriptig 
> bridge. Based on Apples documentation I do the following:
>
> NSDictionary *propes = [NSDictionary 
> dictionaryWithObjectsAndKeys:@"ZZZ", @"name", vis, @"visible", nil];
> iTunesPlaylist *myPlaylist = [[[iTunes 
> classForScriptingClass:@"playlist"] alloc] initWithDictionary:propes];


s/initWithDictionary:/initWithProperties:/


> [myUserPlaylists addObject:myPlaylist];



Be aware that -[SBElementArray addObject:] is borked on iTunes and 
various other applications; see the following thread for details:

http://lists.apple.com/archives/Applescript-implementors/2007/Nov/threads.html#00034

One possible workaround is to use -insertObject:atIndex:, but that 
only works if there's already one or more elements present. Another 
possibility is to forgo SB's weird object creation process and 
construct your own 'make' command using -[SBObject 
sendEvent:id:parameters:].

Another option would be to use objc-appscript:

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

which speaks Apple events the same way that AppleScript and the Apple 
Event Manager do, allowing you to compose a 'make' command with the 
correct parameters without having to resort to raw AE codes and stuff. 
While objc-appscript isn't entirely finished (working on it), it's 
already more functional and provides better application compatibility 
than Scripting Bridge.

HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

Related mailsAuthorDate
mlAdding playlists to iTunes with SB Eddy Hatcher Nov 24, 12:26
mlRe: Adding playlists to iTunes with SB has Nov 24, 16:03