0

I'm working with cocoalibspotify. I want know how to have SPPlaylistItem from SPPlaylist? I've my own playlist. How can I obtain playlistitem using playlist(by name)?

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34

1 Answers1

0

huh.. finally I got my answer.I found the way for getting playlistitem from playlist.

During my research I came to know that playlist items are coming from the keypath @unionOfArrays.items. So by removing that I can get the list of playlist only, instead of playlistitem .

Refer my code here :

    // arrPlaylist -> mutablearray which stores the value of loaded playlist in order to use it later 
    // tblPlaylist -> Tablename which displays list of playlist. 

[SPAsyncLoading waitUntilLoaded:[SPSession sharedSession] timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedession, NSArray *notLoadedSession) 
    {
        // The session is logged in and loaded — now wait for the userPlaylists to load.
        NSLog(@"[%@ %@]: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), @"Session loaded.");

        [SPAsyncLoading waitUntilLoaded:[SPSession sharedSession].userPlaylists timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedContainers, NSArray *notLoadedContainers) 
        {
            // User playlists are loaded — wait for playlists to load their metadata.
            NSLog(@"[%@ %@]: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), @"Container loaded.");

            NSMutableArray *playlists = [NSMutableArray array];
            [playlists addObject:[SPSession sharedSession].starredPlaylist];
            [playlists addObject:[SPSession sharedSession].inboxPlaylist];
            [playlists addObjectsFromArray:[SPSession sharedSession].userPlaylists.flattenedPlaylists];

            [SPAsyncLoading waitUntilLoaded:playlists timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedPlaylists, NSArray *notLoadedPlaylists) 
            {
                // All of our playlists have loaded their metadata — wait for all tracks to load their metadata.
                NSLog(@"[%@ %@]: %@ of %@ playlists loaded.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), 
                      [NSNumber numberWithInteger:loadedPlaylists.count], [NSNumber numberWithInteger:loadedPlaylists.count + notLoadedPlaylists.count]);
                            NSLog(@"loadedPlaylists >> %@",loadedPlaylists);

                arrPlaylist = [[NSMutableArray alloc] initWithArray:loadedPlaylists];
                NSLog(@"arrPlaylist >> %@",arrPlaylist);

                [tblPlaylist reloadData];
            }];
        }];
    }];
Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34