Created
February 25, 2012 15:32
-
-
Save sommestad/1909096 to your computer and use it in GitHub Desktop.
Moving a playlist to a folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (_appFolder) { | |
NSArray * containerPlaylists = container.playlists; | |
for (SPPlaylist * containerPlaylist in containerPlaylists) { | |
// move all playlists tagged with SpotON Radio: | |
if ([containerPlaylist.name rangeOfString: kPlaylistNameMatch].location != NSNotFound) { | |
NSInteger playlistIndex = [[container playlists] indexOfObject: containerPlaylist]; | |
DLog(@"-> MOVE playlist %@ at index %i", containerPlaylist.name, playlistIndex); | |
// retain playlist while working with it | |
[containerPlaylist retain]; | |
// move playlist | |
NSError * error = nil; | |
BOOL success = [container movePlaylistOrFolderAtIndex:playlistIndex ofParent: nil toIndex: 0 ofNewParent: _appFolder error: &error]; | |
if (success) { | |
// rename playlist | |
DLog(@"Success! Playlist moved to folder (error: %@).", error); | |
// check the folder structure | |
for (SPPlaylist * folderPlaylist in [_appFolder playlists]) { | |
DLog(@"Playlist %@ in folder...", folderPlaylist.name); | |
} | |
} else { | |
DLog(@"Failed to move playlist %@ with error: %@", containerPlaylist.name, error); | |
} | |
// release playlist | |
[containerPlaylist release]; | |
} | |
} | |
} |
The log output on #23-#25 doesn't print out anything and the structure doesn't look right in Spotify.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_appFolder
is a previously stored instance var, representing the folder to which I want to move the playlist.When I'm running this code, I'm getting the "success" message, the folder and playlist is created in Spotify (with an added track), but the playlist hasn't been moved to the folder.