我正在尝试创建一个可以执行函数的完成块,但我不断收到错误消息:
无法将类型“()”的值转换为预期的参数类型“()-> Void”
这是功能:
var labelViews : [LabelViews] = []
private func removeAllLabels(completion: (() -> Void)) {
guard let mapController = viewModel.mapController,
let currentMap = mapController.currentMap else {
return
}
LabelViews.forEach { view in
DispatchQueue.main.async {
mapController.removeComponent(view, on: currentMap)
}
}
completion()
}
但是当我尝试使用它时,我得到了错误:
self.removeAllCampusLabels(completion: self.labelViews.removeAll()) // error happens here