Swift: SKAction.runBlock & # 8594; Missing argument to completion parameter in BUT WHY?

I am not in Swift. I can not understand why this code:

class GameScene: SKScene, SKPhysicsContactDelegate { var statements = Statements() override func didMoveToView(view: SKView) { runAction(SKAction.repeatActionForever( SKAction.sequence([ SKAction.runBlock(addLabel(statements)), SKAction.waitForDuration(2.0) ]) )) } func addLabel(statements: Statements) {...} } 

Results: Missing argument for completion parameter on call

+5
source share
1 answer

Another weird type checking error. Since the type self.addLabel(self.statements) not Void -> Void it Void , the compiler suggested that you call another method somewhere else (where it is somewhere else, I have no idea. There is no method called runBlock(_:) anywhere I can find). Try explicit closure when something like this happens

 class GameScene: SKScene { var statements = Statements() override func didMoveToView(view: SKView) { runAction(SKAction.repeatActionForever(SKAction.sequence([ SKAction.runBlock({ self.addLabel(self.statements) }), SKAction.waitForDuration(2.0) ]))) } func addLabel(statements: Statements) -> Void { } } 
+10
source

Source: https://habr.com/ru/post/1204859/


All Articles