嗨我試圖從用戶帶星號的歌曲中提取藝術家。我明白,starredListForUserInSession返回一個PlaylistSnapshot。這有一個第一個TrackPage屬性,它是一個SPTListPage。Spotify iOS SDK返回SPTListPage.items返回零
在我的測試中,當打印出SPTListPage時,它說該列表有8個項目。當我嘗試使用ListPage.items獲取ListPage中的項目時,它返回nil。我不確定有什麼問題。我打電話錯了嗎?
func retrieveStarred() -> Void {
SPTRequest.starredListForUserInSession(self.session, callback: { (error:NSError!, starred: AnyObject!) -> Void in
if error != nil {
println("error retrieving starred playlist")
} else {
self.starred = starred as SPTPlaylistSnapshot
self.scrapePlaylist(self.starred)
}
})
}
func scrapePlaylist(playlist: SPTPlaylistSnapshot) -> Void {
println(playlist);
var firstTracks = playlist.firstTrackPage
println(firstTracks)
println(firstTracks.hasNextPage)
var songs = firstTracks as SPTListPage
println(songs.items)
for song in songs.items {
var track = song as SPTPartialTrack
for artist in track.artists {
updateSongsCount(artist as SPTPartialArtist)
}
}
}
你有沒有想過這個?我有同樣的問題。謝謝 – David 2017-08-29 15:37:42