我已经将我的代码更新为Xcode 8.0 beta 6,但我似乎陷入了关于新的非转义关闭默认值的问题.在下面的代码中,Xcode建议在下面代码的第一行@escaping前面添加completion:,但是仍然不会编译并进入圆圈.*
(编辑:事实上,@scaping应该在之后 添加completion:,正如Xcode建议的那样.警报可能仍然显示,但清理和编译将删除它.)*如何重新编写/修复此代码以在更新的Swift 3中工作?我看过新手册,但找不到合适的代码示例.
func doSomething(withParameter parameter: Int, completion: () -> ()) {
// Does something
callSomeOtherFunc(withCompletion: completion)
}
// Calling the method and execute closure
doSomething(withParameter: 2) {
// do things in closure
}
Run Code Online (Sandbox Code Playgroud)
任何帮助非常感谢!