ABMSoundCloudAPI:将 Objective-C 块转换为 Swift 闭包

ABMSoundCloudAPI: Convert Objective-C block to Swift closure

我正在使用来自 (https://github.com/andresbrun/ABMSoundCloudAPI) 的 ABMSoundCloudAPI。

我正在尝试将 Objective-C 块转换为 Swift 块。我正在使用 Xcode 7.

Objective-C

- (void)requestSongById:(NSString *)songID
            withSuccess:(void (^)(NSDictionary *songDict))successBlock
                failure:(void (^)(NSError *error))failureBlock;

我在 Swift 中尝试了以下方法:

SoundCloudPort.requestSongById(songID, withSuccess: {(songDict) -> Void in successBlock()}, failure: {(error) -> Void in failure()})

它给我一个错误,指出“调用中有额外参数 'withSuccess'。

如果有人能帮助我感激不尽

func soundcloudTrackIDConvert(trackID: String) -> String{
    let partOne = "https://api.soundcloud.com/tracks/"
    let partTwo = "/stream?client_id="
    let clientID = "0000"
    let trackID = "0000"
    let completeURL = partOne + trackID + partTwo + clientID
    print("completeURL: \(completeURL)")
    return completeURL
}