How to search for tracks using soundcloud Sdk iOS

I read the soundcloud sdk documentation for iOS and doesn't seem to say anything about finding songs, although he did talk about listing tracks from an existing soundcloud user. So are there any resources or examples? Thanks a million!

+8
api ios objective-c sdk soundcloud
source share
1 answer

You should use this format:

https://api.soundcloud.com/me/tracks?q=SEARCHTEXT&format=json

Just remember that if the user enters a space, you must replace it with %20 , you can achieve this with

NSString *search = [originalSearch stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

Then just request the JSON data as follows:

 [SCRequest performMethod:SCRequestMethodGET onResource:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.soundcloud.com/me/tracks?q=%@&format=json", search]] usingParameters:nil withAccount:[SCSoundCloud account] sendingProgressHandler:nil responseHandler:^(NSURLResponse *response, NSData *data, NSError *error) { 

My last code is as follows:

  NSString *search = [searchBar.text stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; [SCRequest performMethod:SCRequestMethodGET onResource:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.soundcloud.com/me/tracks?q=%@&format=json", search]] usingParameters:nil withAccount:[SCSoundCloud account] sendingProgressHandler:nil responseHandler:^(NSURLResponse *response, NSData *data, NSError *error) { NSError *jsonError; NSJSONSerialization *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; if (!jsonError && [jsonResponse isKindOfClass:[NSArray class]]) { self.searchQuery = (NSArray *)jsonResponse; [self.tableView reloadData]; } else { NSLog(@"%@", error.localizedDescription); } }];` 

I hope this helps!

+9
source share

All Articles