3

我不知道你们中是否有人已经在使用最近可用的用于 spotify 的 API,但有一些东西让我很烦恼。

一旦你通过了-(void)sessionDidLoginSuccessfully:(SPSession *)aSession回调,几乎没有信息是SPSession对象。

但是对 CocoaLibSpotify 进行一些代码检查,这似乎很正常,稍后会检索数据。

问题是,似乎这些信息实际上从未被检索到。我遵循了与他们的“Guess the Intro”示例类似的行为,如果我这样做:

- (void)sessionDidLoginSuccessfully:(SPSession *)aSession
{
    // trying to fetch another piece of info about the user
    userTopList = [[SPToplist toplistForCurrentUserInSession:session] retain];
    [self waitForReadiness];
}

- (void)waitForReadiness
{
    // Event after 10 seconds userPlaylists is still nil
    if (![[[SPSession sharedSession] userPlaylists] isLoaded])
    {
        playlistsAttempts++;

        if (playlistsAttempts < 10) 
        {
            [self performSelector:_cmd withObject:nil afterDelay:1.0];
            return;
        }
    }
    // However, after only 1 second, userTopList is fetched
    if (userTopList.isLoaded )
        { /* do stuff */ }

}

基本上,在主会话保持不变的userTopList情况下,不到一秒钟就正确设置了。userPlaylistsnil

在给定的例子中,同样的事情正在发生。

所以我开始认为这个库还没有完全到位,但我很乐意接受你的意见。

4

1 回答 1

3

我遇到了同样的问题,发现以下补丁解决了我的问题:

https://github.com/spotify/cocoalibspotify/commit/2c9b85e306a8849675e5b30169481d82dbeb34f5

希望这可以帮助。

-DX

于 2011-09-14T21:58:08.797 回答