Obtaining a lists of artists using cocoalibspotify for iOS

谁都会走 提交于 2019-12-19 10:49:13

问题


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:


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"]);
}];


来源:https://stackoverflow.com/questions/10726308/obtaining-a-lists-of-artists-using-cocoalibspotify-for-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!