私は最新の迅速なアプリケーションで、Alamofireと一緒にほとんどのネットワークコードを実行するためにPromiseKitを使用しています。私は私のリターンは私が望むものでない場合にスローするようにセットアップするために私の約束をしようとしている - ここでのコードは次のようになります。このコードは、ドーリーちょうど互角の作品Swift Promise Kitとスロー
`
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) {
//
}
}
`
私がそこに「スロー」ステートメントを持っていない場合、エラーを印刷するか、そこにアラートコントローラコードを入れるだけで、期待どおりに動作します。しかし、私がスローを追加すると、私はエラーの行にコンパイラの赤い旗が表示されるCannot call value of non function type 'ErrorType'
任意の考えですか?ありがとう
以降です。ありがとう! –