我正在使用 iTunes Scripting Bridge 在 iTunes 中搜索用户的音乐。不幸的是,当我启用 App Sandbox 并使用 iTunes.h 中的以下方法时:
(iTunesTrack *) searchFor:(NSString *)for_ only:(iTunesESrA)only;
它只返回零。但是,如果我禁用 App Sandboxing,它就可以正常工作。我似乎无法弄清楚我需要在我的权利文件中包含哪些权利才能使其正常工作。有任何想法吗?
我的代码:
SBElementArray *iTunesSources = [self.iTunes sources];
iTunesSource *library;
for (iTunesSource *thisSource in iTunesSources) {
if ([thisSource kind] == iTunesESrcLibrary) {
library = thisSource;
break;
}
}
SBElementArray *libraryPlaylists = [library libraryPlaylists];
iTunesLibraryPlaylist *libraryPlaylist = [libraryPlaylists objectAtIndex:0];
SBElementArray* searchTracks = (SBElementArray *)[libraryPlaylist searchFor:searchTerm only:iTunesESrAAll];
我的 App.entitlements 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.iTunes</key>
<array>
<string>com.apple.iTunes.library.read-write</string>
<string>com.apple.iTunes.playback</string>
<string>com.apple.iTunes.playerInfo</string>
</array>
</dict>
</dict>