【发布时间】:2019-06-14 02:31:09
【问题描述】:
我测试了一个基于this example 的小型 OSX 应用程序,它使用 AppleScript 的桥接从 iTunes 获取简单信息。
就像我在 ComboDrums 的评论中所说的(是我),我有一个脚本可以将我所有的 iTunes 播放列表放在树中,但是一旦返回比简单的字符串更复杂,它就会失败。
所以我正在寻找将返回的 AppleScript 列表转换为 Swift 友好对象的方法。
有什么想法吗?
谢谢。
脚本:
to getStaticPlaylistsTree()
tell application "iTunes"
set theList to {{theName:"Bibliothèque", theID:"66270731FDBE2C50", isFolder:false, theClass:library playlist, isSmart:false, theCount:37581}, {theName:"Clips vidéo", theID:"07D5032B96891D67", isFolder:false, theClass:user playlist, isSmart:true, theCount:283}}
end tell
return theList
end getStaticPlaylistsTree
【问题讨论】:
-
请发布您的代码。
-
代码在项目示例中(github.com/hhas/Swift-AppleScriptObjC)。我刚刚添加了一个方法来获取一些播放列表的静态树,例如: getStaticPlaylistsTree() 告诉应用程序“iTunes”将 theList 设置为 {{theName:"Bibliothèque", theID:"66270731FDBE2C50", isFolder:false, theClass:library playlist, isSmart:false, theCount:37581}, {theName:"Clips vidéo", theID:"07D5032B96891D67", isFolder:false, theClass:user 播放列表, isSmart:true, theCount:283}} end tell 返回 theList。谢谢。
-
请在问题中发布格式化代码。
-
我无法格式化代码,因为我无法使用我的帐户发布答案... ????很抱歉,但我不能。您可以在简单的 AppleScript 脚本中复制/粘贴代码吗?是一样的... getStaticPlaylistsTree() 告诉应用程序“iTunes”将 theList 设置为 {{theName:"Bibliothèque", theID:"66270731FDBE2C50", isFolder:false, theClass:library playlist, isSmart:false, theCount:37581} , {theName:"Clips vidéo", theID:"07D5032B96891D67", isFolder:false, theClass:user 播放列表, isSmart:true, theCount:283}} end tell return theList end getStaticPlaylistsTree
标签: arrays swift macos applescript itunes