macos - 如何在 MacRuby 中将 NSPopUpButton 与 ITUnesPlaylist 对象绑定(bind)?

标签 macos cocoa itunes macruby scripting-bridge

我正在尝试使用 ITUnesPlaylist 对象数组填充 NSPopUpButton。我将 NSArrayController 绑定(bind)到 NSPopUpButton

app = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes")
playlists = app.sources.objectWithName("Library").userPlaylists

myArrayController.setContent playlists

所有播放列表都会出现在 NSPopUpButton 中,但它们的名称都带有

<ITunesUserPlaylist:0x4018a5000: iTunesUserPlaylist 0 of iTunes Source "Library" of Application "iTunes" (51822)>

我想做的是将 ITUnesPlaylist.name 绑定(bind)到 NSPopUpButton 的内容值,但我似乎无法让它工作。

有关 Scripting Bridge API 调用返回的对象的类定义的文档似乎也很少(例如 ITunesPlaylist、ITunesTrack)。

有人可以给我一些指点吗?最终我想制作一个下拉菜单,以分层形式显示用户的 iTunes 播放列表。

最佳答案

您确定使用正确的 key 路径正确设置了绑定(bind)吗?您还加载了bridgesupport 文件吗? 我验证了 ITUnesUserPlaylist 类,它应该符合 KVC 标准。

playlists.first.valueForKey('name')

返回正确的名称。

如果您分享更多代码,我可能会调查这个问题。

此外,以下是您的播放列表中可用的一些方法:

Class: iTunesPlaylist
Properties:
duration (the total length of all songs (in seconds))
name (the name of the playlist)
parent (folder which contains this playlist (if any))
shuffle (play the songs in this playlist in random order?)
size (the total size of all songs (in bytes))
songRepeat (playback repeat mode)
specialKind (special playlist kind)
time (the length of all songs in MM:SS format)
visible (is this playlist visible in the Source list?)

Method: tracks
Returned: SBElementArray
----
Method: moveTo:(SBObject *)to
Returned: void
Move playlist(s) to a new location
----
Method: searchFor:(NSString *)for_ only:(iTunesESrA)only
Returned: iTunesTrack
search a playlist for tracks matching the search string. Identical to entering search text in the Search field in iTunes.

Class: iTunesUserPlaylist
Properties:
shared (is this playlist shared?)
smart (is this a Smart Playlist?)

Method: fileTracks
Returned: SBElementArray
----
Method: URLTracks
Returned: SBElementArray
----
Method: sharedTracks
Returned: SBElementArray
----

关于macos - 如何在 MacRuby 中将 NSPopUpButton 与 ITUnesPlaylist 对象绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9471070/

相关文章:

ios - iAd付款细节

python - 在 Mac OS 10.13(High Sierra) 上导入 pygame 模块时遇到问题!

iphone - 有没有一种简单的方法可以按键值对 plist(字典数组)进行排序?

python - 使用 Python 和 Scripting Bridge 在 iTunes 中创建播放列表

iphone - iTunes 商店中的应用程序名称相同吗?

xcode - 如何将自定义的 cocoa 框架嵌入到 mac os x 应用程序中?

java - 如何将文件图标添加到标题栏,并指示 Mac 上的 JavaFX 中未保存某些内容?

macos - 无法在 Vim 中映射 <S-CR>

macos - 我如何使用 bash 和 xmllint 解析 adobe xml swidtag

cocoa - 我想要为我的第一个 cocoa 应用程序提供一个漂亮的自定义窗口