I'm trying to create a completion block where a function can be executed but I keep getting the error:
Cannot convert value of type '()' to expected argument type '() -> Void'
Here is the function:
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()
}
But when I try and use it I get error:
self.removeAllCampusLabels(completion: self.labelViews.removeAll()) // error happens here