I keep getting a finish block error in swift. The error is:
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)
})
}
Don't specify the argument labels when you call
blockFinih
. You've defined it to have no argument labels. The parametersselectedTags
andunSelectedTags
can only be used inside the function, not by the caller.Change:
to: