I need a closure method executed on demand.
In Swift 3 I used to do something like this:
// Declare closure
var checksPerformed: ((Void) -> Void)? // Declaration
// Call when needed
checksPerformed?()
//Only executes when checksPerformed is called
checksPerformed = { _ in
// do stuff here
}
In Swift 4 this is no longer the case.

And after fixing this warning nothing works as before. What is the new way of doing this?
If I'm updating the declaration to: var checksPerformed: (() -> ())? I'm getting

Distinguish between single-tuple and multiple-argument function types
// Declare closure
var checksPerformed: (() -> ())? // Declaration
// Call when needed
checksPerformed?()
//Only executes when checksPerformed is called
checksPerformed = {
// do stuff here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With