iTunesApplication *iTunes = [SBApplication applicationWithBundleIDentifIEr:@"com.apple.iTunes"];SBElementArray *iSources = [iTunes sources];iTunesSource *library = nil;for (iTunesSource *source in iSources) { if ([[source name] isEqualToString:@"library"]) { library = source; break; }}// Could not find the itunes libraryif (!library) { NSLog(@"Could not connect to the iTunes library"); return;}// Now look for our playListNsstring *playListname = @"new playList";SBElementArray *playLists = [library userPlayLists];iTunesUserPlayList *playList = nil;for (iTunesUserPlayList *thisList in playLists) { if ([[thisList name] isEqualToString:playListname]) { playList = thisList; break; }}// if the playList was not found,create itif (!playList) { playList = [[[iTunes classForScriptingClass:@"playList"] alloc] init]; ; [[library userPlayLists] insertObject:playList atIndex:0];}
当我尝试添加播放列表的名称时,我收到错误消息:
iTunesBrIDge[630:80f] *** -[SBProxyByClass setname:]: object has not been added to a container yet; selector not recognized
任何人都可以指向正确的方向吗?
解决方法 错误消息告诉您,像播放列表之类的Scripting BrIDge对象在添加到相关的SBElementArray之前无法接收消息,因此在将播放列表添加到数组之前尝试设置属性失败.最简单的解决方案是重新排列最后两行代码,如下所示:
// if the playList was not found,create itif (!playList) { playList = [[[iTunes classForScriptingClass:@"playList"] alloc] init]; [[library userPlayLists] insertObject:playList atIndex:0]; ;}
另一个选择是使用initWithPropertIEs:根据你对另一个答案的评论是你最终做的.
总结以上是内存溢出为你收集整理的可可 – 使用脚本桥创建iTunes播放列表全部内容,希望文章能够帮你解决可可 – 使用脚本桥创建iTunes播放列表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)