xcode - Class declaration cannot close over value 'fulfill' defined in outer scope - Swift 2.0 -


i'm trying convert app swift 1.2 swift 2.0 , i'm encountering 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 on value 'fulfill' defined in outer scope             }         }     } } 

how can make b (or then closure) capture fulfill properly?

ps: promise comes promisekit, , i'm running xcode 7 beta 1.

you should able workaround assigning fulfill local capture instead.

class b {     func test() -> promise<a> {         return promise<a> { (fulfill, reject) -> void in             let innerfulfill = fulfill // close on instead             anotherpromise.then { _ -> void in                 return innerfulfill(a()) // class declaration cannot close on value 'fulfill' defined in outer scope             }         }     } } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -