0
我正在使用try-catch錯誤處理將我的代碼升級到Swift 2。我堅持關閉(NSURLSession),我不能扔進它。Swift 2:從關閉拋出
一般我用這樣的代碼:
let request = NSURLRequest()
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
if error != nil {
throw(ErrorType) // here some errortype enum
}
}
但我收到的錯誤:「不能與類型的參數列表調用dataTaskWithRequest ...」。我如何從封閉中拋出?