I have adapted code to Swift 5. No issues, no correction to make, compatibility is great.
However, I have a switch case for AVCaptureDevice.authorizationStatus:
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: accessGranted = true
case .notDetermined: AVCaptureDevice.requestAccess(for: .video) { granted in
if granted { accessGranted = true }
}
case .denied:
return
case .restricted:
return
}
I get a (logical) warning: Handle unknown values using "@unknown default"
I am proposed a fix (not always: in a second code, with the exact same sequence, on the same machine, same Switch5 setting, I don't get the fix proposed) to add at the end
@unknown default:
<#fatalError()#>
I accept and implement this:
case .restricted:
return
@unknown default:
return
}
Then error at line 2: Expected expression in 'return' statement
If I add a semi colon after return
case .restricted: // The user can't grant access due to restrictions.
return;
@unknown default:
return
}
Everything OK, and identation correct.
@unknown is interpretated as the argument for return
Is this a known bug ? Or expected behavior ?