2015-09-19 40 views
0

我正在使用來自(https://github.com/andresbrun/ABMSoundCloudAPI)的ABMSoundCloudAPI。ABMSoundCloudAPI:將Objective-C塊轉換爲Swift結束

我試圖將Objective-C塊轉換爲Swift塊。我使用的Xcode 7

Objective-C的

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

我試着在斯威夫特以下幾點:

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

它給了我一個錯誤呼叫聲明「額外的參數 'withSuccess'。

如果有人能幫助我很感激。

+0

一直在尋找這個API。好東西。 – lukaivicev

回答

1
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 
}