Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spotify iOS SDK returning SPTListPage.items returning nil

Tags:

ios

swift

spotify

Hi I'm trying to extract the artists from the the user starred songs. I understand that starredListForUserInSession returns a PlaylistSnapshot. That has a firstTrackPage attribute that's a SPTListPage.

In my test when printing out the SPTListPage, it says the list has 8 items. When I try to get the items in the ListPage with ListPage.items it returning nil. I'm not sure what's wrong. Am I calling the wrong property?

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)
        }
    }
}
like image 461
Dang P Avatar asked Feb 04 '26 20:02

Dang P


1 Answers

I think this page (github.com/spotify/ios-sdk/issues/377) was setup by the same person that asked this question and he did finally figure it out in the comments on that page. I thought I'd paste it here for anyone else with the same issue. The comment on that page worked for me too:

"Ok - Got it fixed

To complete the set up of your build environment, switch from the Info tab to the Build Settings tab and find the Other Linker Flags build setting (you can search for it using the search field at the top of the settings list). If you don’t see it you might need click on ‘All’ to show all build settings.

Add the value -ObjC to this setting." -github.com/spotify/ios-sdk/issues/377

like image 88
David Avatar answered Feb 06 '26 09:02

David