gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 17:15:02 26 4
gpt4 key购买 nike

我正在尝试使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com