我有一个类似下面的函数,但当我执行它时,显示“逃逸闭包捕获'inout'参数'cani'”,我有什么遗漏吗?
func duration(out:Int,h2:Int,rep:Int,cani:inout Bool){
var io = 0
var b = 0
cani = false
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { // "Escaping closure captures 'inout' parameter 'cani'" //
timer in
io += 1
b += 1
if b <= out{
text = "come in"
}else if b <= out + h2 && b > out{
text = "Hold on"
}
if io == (out + h2 ) * rep{
textcange = "End"
timer.invalidate()
cani = true
}
}
}
显示 "逃逸闭包捕获'inout'参数'cani'"