有时您只需要阅读 SDK 本身。
您真正应该问的是如何正确调用以下内容。试试这个。我没有测试过这个。只能猜测。
NSString *streamURL = [track objectForKey:@"stream_url"];
SCAccount *account = [SCSoundCloud account];
[SCRequest performMethod:SCRequestMethodGET
onResource:[NSURL URLWithString:streamURL]
usingParameters:nil
withAccount:account
sendingProgressHandler:nil
responseHandler:^(NSURLResponse *response, NSData *data, NSError *err) {
if (err == nil) {
if ([[NSFileManager defaultManager] fileExistsAtPath:localPath]) {
NSLog(@"Overwriting for import.");
BOOL success = [[NSFileManager defaultManager] removeItemAtPath:localPath error:nil];
if (success) {
NSLog(@"Overwrite successful!");
} else {
NSLog(@"Overwrite failed");
return;
}
}
BOOL success = [[NSFileManager defaultManager] createFileAtPath:localPath contents:data attributes:nil];
if (success) {
NSLog(@"download complete");
} else {
NSLog(@"failed to create a new file");
}
} else {
NSLog(@"Failed to download track.");
}
}];