simonbs
simonbs

Reputation: 8042

Get notified when a playlist is added or removed through cocoalibspotify

I use cocoalibspotify in an application and would like to get notified when a playlist is added or deleted.

I have tried adding an observer for the key path userPlaylists on the shared session but this does not seem to get called. I have also tried implementing the -sessionDidChangeMetadata: delete method but this seems to be only called when logging in.

Does anyone know how to get notified when the user adds or deletes a playlist?

Upvotes: 0

Views: 102

Answers (1)

iKenndac
iKenndac

Reputation: 18776

You need to add a KVO observer to the playlists property of your session's userPlaylists container. You were adding your KVO one step too short. Note that the userPlaylists property will be nil for a short time after logging in, so you need to watch for that change too:

self.session = [SPSession sharedSession];
[self addObserver:self forKeyPath:@"session.userPlaylists.playlists" options:0 context:nil];

Upvotes: 1

Related Questions