Skip to content

Instantly share code, notes, and snippets.

@fotiDim
Last active August 29, 2015 14:15
Show Gist options
  • Save fotiDim/b4d7d32e5e5775bb26c5 to your computer and use it in GitHub Desktop.
Save fotiDim/b4d7d32e5e5775bb26c5 to your computer and use it in GitHub Desktop.
Find all working Spotify genres.
//Set these properties
@property NSMutableArray *genres;
@property int counter;
@property NSMutableArray *workingGenres;
//Set counter to 0
_counter=0
//Populate the "genres" array with the NSStrings of your genres
//call the method
[self lookupwithString:_genres[_counter]];
-(void) lookupGenrewithString:(NSString*)genre{
NSString *searchString = [[NSString alloc]initWithFormat:@"genre:\"%@\"",genre];
_counter++;
[SPTRequest performSearchWithQuery:searchString queryType:SPTQueryTypeArtist session:_session market:@"from_token" callback:^(NSError *error, SPTListPage *listPage) {
if (error != nil) {
NSLog(@"*** Working Genre %@ Lookup got error %@", genre, error);
return;
}
if ([listPage.items count] > 0){
NSLog(@"Added %@ to list",genre);
[_workingGenres addObject:genre];
}
if (_counter >= [_genres count])
NSLog(@"Working genres list: %@",[_workingGenres description]);
else
[self lookupGenrewithString:_genres[_counter]];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment