completion: { (finished: Bool) in
...
seal.reject(finished as! Error) // casting error
...
Во-первых, закончено является логическим значением, вы не можете принудительно вызвать его как Ошибка .Если вы хотите отказаться с ошибкой, вы должны запустить Error , как показано ниже.
let error = NSError(domain: "some information", code: 0, userInfo: nil) as Error
reject(error)
Во-вторых, я не знаю, почему вы хотите отклонить в середине кода, это нарушит всю цепочку обещаний.Вы должны выполнить обещание после того, как все сделано правильно.
}, completion: { (finished: Bool) in
UIView.animate(withDuration: 0.5) {
self.topLabel.alpha = 1
self.mainText.alpha = 1
}
self.topLabel.text = "user says".uppercased()
self.mainText.text = newText
self.setLabel(self.cityLabel)
self.setLabel(self.streetLabel)
self.setLabel(self.countryLabel)
self.setLabel(self.dateLabel)
self.setLabel(self.speechLabel)
self.setLabel(self.itentLabel)
self.setLabel(self.conditionLabel)
self.setLabel(self.outfitLabel)
self.setLabel(self.scoreLabel)
// fulfill your promise right here
})
...