This code:
runAction(moveleft, completion: nil)
Gives error:
Nil is not compatible with expected argument type '() -> Void'
Why is that?
This code:
runAction(moveleft, completion: nil)
Gives error:
Nil is not compatible with expected argument type '() -> Void'
Why is that?
Not sure if this is new with Swift 4 but I had to use
{_ in }
hope this is helpful to someone
The function's runAction
completion handler is type of Void
which means, it cant pass nil
as an argument.
To be able to pass nil
as the argument, change the completions handler type from Void
to Void?
.
I guess you are referring to SKNode.runAction()
. In that case, completion
is a closure that accepts no argument and return nothing either. It is to be executed after the action has completed.
There is a runAction
that doesn't require a completion
parameter. You should use that:
runAction(moveleft)