I´m using cocoalibspotify(great stuff) for streaming Spotify music in my project.
After choosing a playlist this code runs:
[[SPSession sharedSession] playlistForURL:myPlaylistUrl callback:^(SPPlaylist *playlist) {
if(playlist != nil){
_chosenPlaylist = playlist;
}
}];
I later use _chosenPlaylist
to create an array of all tracks. This works just fine for the first playlist I choose. However, when I choose another playlist (or the same one again) the block variable playlist
is nil, which causes a crash.
Note: Before choosing the second playlist I dismiss the view controller so it should act the same way as it does the first time.
Any ideas on why playlist returns as nil the second time I run this code?
Edit:
I´m using ARC.
The declaration for _chosenPlaylist looks like this SPPlaylist *_chosenPlaylist;
The crash occurs because of this line: [playlists addObject:_chosenPlaylist];
, which makes sense since _chosenPlaylist is nil in this situation.