我不知道你们中是否有人已经在使用最近可用的用于 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
情况下,不到一秒钟就正确设置了。userPlaylists
nil
在给定的例子中,同样的事情正在发生。
所以我开始认为这个库还没有完全到位,但我很乐意接受你的意见。