Can someone explain what completionHandler: ((Bool) -> Void) means?
For instance it appears when requesting camera access:
AVCaptureDevice.requestAccess(for: AVMediaType.depthData, completionHandler: (<#T##(Bool) -> Void#>))
I usually do this to check if access was granted or not:
func requestCamera() {
AVCaptureDevice.requestAccess(for: AVMediaType.video) { (response) in
if response {
print("true")
} else {
print("denied")
}
}
}
Obviously I do stuff there, but that doesn't matter here. I just want to understand what ((Bool) -> Void) means and why I have to use the completion handler here. With other functions I can just set the handler to nil, but in this case it expects a response in some way.
So what does this mean?