그래서 Alamofire와 함께 네트워킹 코드의 대부분을 수행하는 최신의 신속한 응용 프로그램에서 PromiseKit을 사용하고 있습니다.Swift Promise Kit 및 throws
`
do{
firstly({
try DoStuff.doStuff()
}).then({ response in
self.array = response
}).error { error in
throw Error.GeneralError
print(error)
}
firstly({
try DoOtherThing.otherThing()
}).then({ response in
self.stuff = response
}).error{ error in
throw TransactionError.GeneralError
print(error)
}
} catch {
let alertController = UIAlertController(title: "Network Error", message: "Network error, please try again", preferredStyle: .Alert)
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
//
}
alertController.addAction(OKAction)
self.presentViewController(alertController, animated: true) {
//
}
}
`
이 코드는 도리 단지 늠름한 작동 :처럼 여기 코드가 어떻게 표시되는지를 보여줍니다 - 내 반환 내가 원하는 것을하지 않을 때 던져 설정에 내 약속을 시도하고있다 거기에 'throw'문이 없으면 오류를 인쇄하거나 거기에 경고 컨트롤러 코드를 넣으면 예상대로 작동합니다. 하지만 던지기를 추가하면 컴파일러의 붉은 깃발이 '오류'란에 표시됩니다. Cannot call value of non function type 'ErrorType'
어떤 생각을하고 있습니까? 감사합니다
이후로. 감사! –