I have been trying to use PromiseKit, and I'm stuck at rejecting a promise.
Promise rejection is done either by calling a reject function with an NSError as argument.
func getAPromise() -> Promise<Bool> {
return Promise<Bool> { fulfiller, rejecter in
let diceRoll = Int(arc4random_uniform(7))
if diceRoll < 4 {
// rejecter(?) how do I call this rejection correctly ?
} else {
fulfiller(true)
}
}
Simply getting an instance of NSError would help me.
EDIT:
NSError("somedomain", 123, [])
complains with "Extra argument in call".
You have two problems in this code:
NSError
have external name.Dictionary
literal is[:]
, not[]
.[]
is forArray
Try:
Or, if you don't have any
userInfo
, you might want to passnil
for it.