Trying to get the whole track in a users playlist, it works in an Objective-C demo application, but when I try in Swift, it returns this:
<SPTPlaylistList: 0x7fca22d72460>: 0-0 of 1 items (Function)
I am using this code:
SPTPlaylistList.playlistsForUserWithSession(session, callback: { (error, object) -> Void in if error == nil { var playlists = object as! SPTListPage println(playlists) SPTPlaylistSnapshot.playlistWithURI(playlists.items[0].uri, accessToken: session.accessToken, callback: { (error:NSError!, obj) -> Void in var playl = obj as! SPTPlaylistSnapshot println(playl.firstTrackPage.tracksForPlayback) }) } })
and this is Objective-C code that works:
[SPTPlaylistList playlistsForUserWithSession:session callback:^(NSError *error, id object) { SPTListPage *aa = object; NSLog(@"%@",aa.items); [SPTPlaylistSnapshot playlistWithURI:[NSURL URLWithString:@"spotify:user:spotifizr:playlist:3bpGFVfycGnhtcEVb95G98"] accessToken:session.accessToken callback:^(NSError *error, SPTPlaylistSnapshot *object) { NSLog(@"tracks on page 1 = %@", [object.firstTrackPage tracksForPlayback]); }]; }];
Not sure why it returns (function) in a Swift project instead of all tracks.
Edit: Tried
println(playl.firstTrackPage.tracksForPlayback())
but now it returns nil, although I have 50 tracks in the playlist.
ios spotify swift
Ankit
source share