Scripting Bridge generates error creating a new playlist in iTunes on 10.5, but not 10.6

Posted by Simone Manganelli on Stack Overflow See other posts from Stack Overflow or by Simone Manganelli
Published on 2010-04-13T10:15:32Z Indexed on 2010/04/13 19:03 UTC
Read the original article Hit count: 350

Filed under:
|

I'm having a problem with the Scripting Bridge framework in 10.5. Specifically, I use this code to create a new user playlist in iTunes:

NSDictionary *propertiesDict = [NSDictionary dictionaryWithObject:@"playlistName" forKey:@"name"];
playlistToReturn = (iTunesUserPlaylist*)[[[iTunesApp classForScriptingClass:@"user playlist"] alloc] initWithProperties:propertiesDict];
SBElementArray *sourcesArray = [iTunesApp sources];
iTunesSource *librarySource = [sourcesArray objectAtIndex:0];
SBElementArray *userPlaylistsArray = [librarySource userPlaylists];
[userPlaylistsArray addObject:playlistToReturn];

This code works fine in 10.6. The playlist is created correctly, and I can add songs to it later.

However, on 10.5, an error is generated:

Apple event:'core'\'crel'{
'kocl':'cUsP',
'insh':'insl'{
              'kobj':'obj '{
                            'want':'cUsP',
                            'from':'obj '{
                                          'want':'cSrc',
                                          'from':'null'(),
                                          'form':'ID  ',
                                          'seld':42 },
                            'form':'indx',
                            'seld':'abso'($206C6C61$) },
              'kpos':'end ' },
'prdt':{
              'pnam':'utxt'("playlistName") }
};

Error Domain=SBError Code=-10014 UserInfo=0x152c8cb0 "Operation could not be completed. (SBError error -10014.)"

Why?

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about scripting-bridge