Cat Simoes
Cat Simoes

Reputation: 65

After SPTYourMusic request, the response containing SPTListPage has items as nil

I'm trying to get the user's Saved Tracks using the following code snippet:

func getYourMusicLibrary() {
    let accessToken = SPTAuth.defaultInstance().session.accessToken
    let request: URLRequest = try! SPTYourMusic.createRequestForCurrentUsersSavedTracks(withAccessToken: accessToken)

    SPTRequest.sharedHandler().perform(request) { (error, response, data) in
        if error == nil {
            let listPage = try! SPTListPage(from: data, with: response, expectingPartialChildren: false, rootObjectKey: nil)
            let items = listPage.items

The listPage.items is always nil. I also tried to set rootObjectKey of the SPTListPage constructor to the expected object type result SPTSavedTrack and expectingPartialChildren to true. Also listPage.totalListLength has a number of tracks that is consistent with the number of tracks I have in my Songs list in My Music.

Any ideas of what I might be doing wrong here?

Upvotes: 1

Views: 93

Answers (1)

Cat Simoes
Cat Simoes

Reputation: 65

To fix this issue I had to add -ObjC in "Other Linked Flags" in the Build Settings of the project.

Upvotes: 1

Related Questions