swift - nil 与预期的参数类型 '() -> Void' 不兼容

标签 swift swift2

SKAction.group([moveToAction, SKAction.fadeAlphaTo(1.0, duration: 0.2)]), completion:nil)

}

runAction(SKAction.waitForDuration(0.2), completion: completion)

当我这样做时,出现错误:

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

最佳答案

() -> Void 不是 Optional 所以它不能是 nil

您应该将空闭包作为completion 参数传递:

..., completion: {})

关于swift - nil 与预期的参数类型 '() -> Void' 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33201215/

相关文章:

string - swift 2 : Iterating and upper/lower case some characters

arrays - 创建并迭代字典数组的数组

swift - 使用字典中设置的图像名称更改 UIImage 图像属性

Swift Playground WebView 不会显示本 map 片

ios - 从 Table View Controller 切换到 Master Detail Controller

ios - Swift 2. 对象之间的 UILabel 碰撞不起作用

ios - 如何使用搜索栏使用 swift 从 json 结果中获取数据?

swift - macOS 上沙盒 swift 应用程序的应用程序间通信

swift - 如何连接两个注释点?

xcode - 安装 Xcode 7 后,Xcode 6.3 显示有关转换为 Swift 2 的错误