I'm trying to convert my app from Swift 1.2 to Swift 2.0 and I'm encountering the following error:
class B {
func test() -> Promise<A> {
return Promise<A> { (fulfill, reject) -> Void in
anotherPromise.then { _ -> Void in
return fulfill(A()) // Class declaration cannot close over value 'fulfill' defined in outer scope
}
}
}
}
How can I make B
(or the then
closure) capture fulfill
properly?
PS: Promise
comes from PromiseKit, and I'm running Xcode 7 beta 1.
You should be able to workaround this by assigning
fulfill
to a local that you capture instead.