I have issues with loading playlists using the SPAsyncLoading class. Sometimes the call does not return at all, sometimes after a long time.
I use the following code to load a playlist from a url:
NSString *playlistUrl = [Config instance].playlistUrl;
[SPPlaylist playlistWithPlaylistURL:[NSURL URLWithString:playlistUrl] inSession:[SPSession sharedSession] callback:^(SPPlaylist *pl) {
playlist = pl;
playlist.delegate = self;
[SPAsyncLoading waitUntilLoaded:playlist then:^(NSArray *array) {
NSLog(@"playlist loaded");
}];
}];
I use the following code to load all of the users playlists:
SPPlaylistContainer *userPlayLists = [[SPSession sharedSession] userPlaylists];
[SPAsyncLoading waitUntilLoaded:userPlayLists then:^(NSArray *result) {
SPPlaylistContainer *userPlayLists = (SPPlaylistContainer*) [result objectAtIndex:0];
[SPAsyncLoading waitUntilLoaded:userPlayLists.playlists then:^(NSArray *result) {
NSLog(@"playlists loaded");
}];
}];
In case of loading all of the users playlists sometimes 0 playlists are loaded, sometimes all playlists are available but the last waitUntilLoaded won't return.
Is there something wrong with my code?