我的 swift 项目中有以下代码
if let availabeDevices = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInMicrophone,
.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back).devices {
captureDevice = availabeDevices.first
}
当我运行此代码时,它在 if 行上显示错误:
Initializer for conditional binding must have Optional type, not '[AVCaptureDevice]'
我尝试?
在之后添加.devices
,但这给出了这个错误:
Cannot use optional chaining on non-optional value of type '[AVCaptureDevice]'
我该怎么办?