Swift 块值错误 [英] Swift Block value error
本文介绍了Swift 块值错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在快速收到完成块错误.错误是:
I keep getting a finish block error in swift. The error is:
不能调用非函数类型的值'((Array,Array)->())!
Cannot call value of non-function type'((Array,Array)->())!
下面还有一张错误图片.代码如下:
There's an image of the error below as well. Here's the code:
var blockFinih: ((_ selectedTags: Array<Tag>, _ unSelectedTags: Array<Tag>) -> ())!
func finishTagController() {
var selected: Array<Tag> = Array()
var unSelected: Array<Tag> = Array()
for currentTag in tags {
if currentTag.isSelected {
selected.append(currentTag)
}
else {
unSelected.append(currentTag)
}
}
self.dismiss(animated: true, completion: { () -> Void in
self.blockFinih(selectedTags: selected, unSelectedTags: unSelected)
})
}
推荐答案
调用 blockFinih
时不要指定参数标签.您已将其定义为没有参数标签.参数 selectedTags
和 unSelectedTags
只能在函数内部使用,不能被调用者使用.
Don't specify the argument labels when you call blockFinih
. You've defined it to have no argument labels. The parameters selectedTags
and unSelectedTags
can only be used inside the function, not by the caller.
变化:
self.blockFinih(selectedTags: selected, unSelectedTags: unSelected)
到:
self.blockFinih(selected, unSelected)
这篇关于Swift 块值错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文