Obtaining a lists of artists using cocoalibspotify for iOS

前端 未结 1 1248
旧巷少年郎
旧巷少年郎 2021-01-16 06:21

I\'d like to quickly get a list of artist names in a user\'s \"library\" or playlists. Is there an easy / asynchronous way to do this?

相关标签:
1条回答
  • 2021-01-16 06:41

    Take a look at the example project "Guess the Intro" included with CocoaLibSpotify. The method waitAndFillTrackPool in that project shows how to get a list of all the tracks in the user's playlists.

    Once you have that list, you can do the following to get the artists from them, put them through a set to thin out duplicates, then wait until they're loaded.

    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"]);
    }];
    
    0 讨论(0)
提交回复
热议问题