【发布时间】:2015-11-08 07:39:18
【问题描述】:
我想澄清一下 Swift 2.1 中的嵌套闭包
这里我声明一个嵌套闭包,
typealias nestedDownload = (FirstItem: String!)-> (SencondItem: String!)->Void
然后我使用这个nestedDownload闭包作为下面函数的参数,并尝试在as这样的函数中完成编译参数值
func nestedDownloadCheck(compliletion:nestedDownload){
compliletion(FirstItem: "firstItem")
}
但这表示错误,“表达式解析为未使用的函数”
另外,当我从ViewDidLoad() 方法调用nestedDownloadCheck() 时,通过tring 填充编译的主体
self.nestedDownloadCheck { (FirstString) -> (SecondString: String!) -> Void in
func OptionalFunction(var string:String)->Void{
}
return OptionalFunction("response")
}
这表示编译错误“Cannot convert return expression of type 'Void'(aka'()') to return Type '(SecondString: String!) -> Void'”
我不知道我究竟是如何以这种方式使用嵌套闭包的。
【问题讨论】:
标签: ios swift2 ios9 ios9.1 swift2.1