6

This code:

runAction(moveleft, completion: nil) 

Gives error:

Nil is not compatible with expected argument type '() -> Void'

Why is that?

Dejan Skledar
  • 11,280
  • 7
  • 44
  • 70
Ryan Mira
  • 61
  • 1
  • 1
  • 7
  • http://stackoverflow.com/questions/32638488/nil-is-not-compatible-with-expected-argument-type-uiviewanimationoptions – Sanju Feb 11 '16 at 09:23

4 Answers4

12

You should pass the parameter {}:

runAction(moveleft, completion: {}) 

as suggested by this answer.

Community
  • 1
  • 1
4

Not sure if this is new with Swift 4 but I had to use

{_ in }

hope this is helpful to someone

1

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?.

Dejan Skledar
  • 11,280
  • 7
  • 44
  • 70
0

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)
Code Different
  • 90,614
  • 16
  • 144
  • 163