xcode - Is it possible to pass closures as variables in Swift? -



xcode - Is it possible to pass closures as variables in Swift? -

take mutual scenario example:

class fooclass { var success:anyobject! -> void var failure:nserror! -> void init() { self.success = ({ object in }) self.failure = ({ error in }) } func request(success:(anyobject! -> void), failure:(nserror! -> void)) { self.success = success self.failure = failure } } extension fooclass: nsurlconnectiondelegate, nsurlconnectiondatadelegate { func connection(connection: nsurlconnection!, didfailwitherror error:nserror!) { println("connection error: \(error)") self.failure(error) } }

looks good... compiling... agh!!! wtf swift?! works in objc!!

i'm absolutely sure compiler error occurring due similar implementation code example.

it seems not thought of closure beingness empty/optional.

can weigh in on this? compiler bug? user error?

xcode segmentation-fault closures swift

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -