Search code examples
iosswiftspotifylibspotify

Spotify API deprecated functions no alternative


Spotify has deprecated some of their functions in the iOS SDK, but has not provided an alternative. I'm having trouble working with one of these functions in Swift. Is there any documentation online that discusses alternatives? Not sure what it means by "use full metadata object instead". Here is what I'm trying to accomplish:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let playListVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("playlistView") as! PlaylistDetailController

    let partial = self.partialPlaylists[indexPath.row] as! SPTPartialPlaylist
    SPTRequest.requestItemFromPartialObject(partial, withSession: self.session) { (error: NSError!, metadata: AnyObject!) -> Void in
        playListVC.snapshot = partial as! SPTPlaylistSnapshot
        playListVC.currentPage = playListVC.snapshot.firstTrackPage
        playListVC.partialPlaylist = partial
        playListVC.session = self.session
        self.navigationController?.pushViewController(playListVC, animated: true)
    }   
}

Can anyone think of a way to do this without using requestItemFromPartialObject


Solution

  • If I read the question right, you're looking for a way to get a full playlist from a partial playlist?

    Here's how:

    let partial = self.partialPlaylists[indexPath.row] as! SPTPartialPlaylist
            SPTPlaylistSnapshot.playlistWithURI(partial.uri, accessToken: self.session.accessToken, callback: {(error: NSError!, result: AnyObject!) -> Void in
                let snapshot = result as! SPTPlaylistSnapshot
                playListVC.snapshot = snapshot
                playListVC.currentPage = snapshot.firstTrackPage
                playListVC.partialPlaylist = partial
                playListVC.session = self.session
                self.navigationController?.pushViewController(playListVC, animated: true)
            })
    

    Basically, you get the uri from the partial playlist and request a SPTPlaylistSnapshot using that uri. The returned "full metadata object" is an SPTPlaylistSnapshot.