【问题标题】:Obtaining a lists of artists using cocoalibspotify for iOS使用 cocoalibspotify for iOS 获取艺术家列表
【发布时间】:2012-05-30 09:02:59
【问题描述】:

我想快速获取用户“库”或播放列表中的艺术家姓名列表。有没有简单/异步的方法来做到这一点?

【问题讨论】:

    标签: spotify cocoalibspotify-2.0


    【解决方案1】:

    查看包含在 CocoaLibSpotify 中的示例项目“Guess the Intro”。该项目中的方法waitAndFillTrackPool 展示了如何获取用户播放列表中所有曲目的列表。

    获得该列表后,您可以执行以下操作以从他们那里获取艺术家,将他们放在一组以减少重复项,然后等到他们加载完毕。

    NSArray *artists = [theTrackPool valueForKeyPath:@"@unionOfArrays.artists"];
    NSArray *uniqueArtists = [[NSSet setWithArray:artists] allObjects];
    
    [SPAsyncLoading waitUntilLoaded:uniqueArtists then:^(NSArray *loadedArtists) {
        // Artists are loaded!
        // Log a list of artist names...
        NSLog(@"%@", [loadedArtists valueForKey:@"name"]);
    }];
    

    【讨论】:

    • 我在猜测介绍应用程序时注意到,当我自己实现它时,最初的“then”块仅返回 2 个播放列表(和 5 个曲目)。当我关闭应用程序并重新打开它时,第二次 waitAndFillTrackPool 会提供所有 6 个播放列表和更多曲目。有什么原因吗?
    • 第一次使用SPAsyncLoading可以获取所有曲目吗?
    • 是的 - 阅读文档到 [SPAsyncLoading waitUntilLoaded:timeout:then:]。您需要增加超时时间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-11
    • 2013-07-05
    相关资源
    最近更新 更多