我一直试图在swift代码中使用iTunes.h ScriptingBridge标头中定义的各种SBElementArray生成器,例如:
(SBElementArray<iTunesPlaylist *> *) playlists;
(SBElementArray<iTunesArtwork *> *) artworks;
但是当我尝试使用与这些数组中包含的类型相关联的方法时:
let playlists: SBElementArray = iTunes.playlists()
if let playlist = playlists[0] as? iTunesPlaylist {
print(playlist.name)
}
我收到编译错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_iTunesPlaylist", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这似乎仅限于SBElementArray,因为使用以下内容访问当前曲目名称没有问题:
let track: iTunesTrack = iTunes.currentTrack;
print(track.name)
我也猜测它与我在代码中尝试从'anyObject'到'iTunesPlaylist'的类型转换有关(我认为我需要打包来访问播放列表内容或我希望展示的任何艺术品),因为以下代码:
let playlists: SBElementArray = iTunes.playlists()
print(playlists[0])
print(type(of: playlists[0]))
corectly返回:
<ITunesPlaylist @0x6080000402d0: ITunesPlaylist 0 of application "iTunes" (93931)>
ITunesPlaylist
答案 0 :(得分:0)
向下转换尝试创建一个可选文件并初始化一个不允许的链接器中不存在的iTunesPlaylist。像您一直知道的那样将其强制为iTunesPlaylist或检查其类型。
animal_class_id