5
只是写了一个简单的快速应用程序,这个错误出现了。Swift:关闭作为参数报告错误
protocol FormDelegate {
func formDidFinish(form: Form)
}
class Form {
var delegate: FormDelegate?
func testClosure(sender:() -> Void) {
}
}
let form = Form()
form.testClosure {
// let removeCommentToGetRidOfError = true
form.delegate?.formDidFinish(form) // error: Cannot convert the expression's type '() ->() -> $T2' to type '()'
}
但是当我插入let语句,一切正常。任何线索怎么回事?
这很有意义。现在即使是错误消息也是有道理的。谢谢:) – warly 2014-09-19 11:39:18
哇,这很有趣。从概念的角度来看,'虚空'与'虚空'有什么不同?可以? – 2014-09-19 11:51:34
'Void?'是可选的,就像'Int?'等等......它可以是'无(None)'或'Void(Some)'。它主要用在可选的链接方法调用中,以告诉方法是否返回曾经调用过的'Void'。 – Kirsteins 2014-09-19 11:58:27