我需要访问用户的iTunes库。我想列出用户从iTunes Store购买或从Apple Music添加到他的音乐库或从其计算机同步并加载的播放列表和专辑之外的所有歌曲。我使用MPMediaQuery
来检索列表。一切看起来都正常,除了运行以下代码时出现错误:
2019-12-10 12:55:01.098885+0300 AppName[11292:2511243] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-12-10 12:55:01.101918+0300 AppName[11292:2511243] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-12-10 12:55:01.124897+0300 AppName[11292:2511243] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-12-10 12:55:01.125093+0300 AppName[11292:2511243] [iTunesCloud] [ICUserIdentityStore] Failed to fetch local store account with error: Error Domain=com.apple.accounts Code=9 "(null)".
代码可以正常工作,并且列出了我在图书馆中拥有的所有物品,包括从iTunes Store购买的物品。我正在努力理解为什么它即使工作仍会打印错误。
let myPlaylistQuery = MPMediaQuery.playlists()
let playlists = myPlaylistQuery.collections
for playlist in playlists! {
print(playlist.value(forProperty: MPMediaPlaylistPropertyName)!)
let songs = playlist.items
for song in songs {
let songTitle = song.value(forProperty: MPMediaItemPropertyTitle)
print("\t\t", songTitle!)
}
}