Using XCode 9, Beta 3. Swift 4.
statsView.createButton("Button name") { [weak self] Void in
//stuff stuff
self?.doSomething()
}
I get hundreds of errors like this, how do I fix them?
Errors:
Cannot convert value of type '(_) -> ()' to expected argument type '() -> ()'
Argument passed to call that takes no arguments
It seems we don't use Void in
in Swift 4 anymore. How I fixed them:
Delete the Void
keyword:
statsView.createButton("Button name") { [weak self] in
//stuff stuff
self?.doSomething()
}
You have to use in
or the compiler with complain with
Expected ',' separator
If there is no arguments then don't use Void in
at all.
statsView.createButton("Button name") { //No "Void in" in here
print("hi")
}