gpt4 book ai didi

swift - 错误=调用中传递了额外的尾随闭包,

转载 作者:行者123 更新时间:2023-12-04 15:26:14 26 4
gpt4 key购买 nike

    //creates the session
let session = AVCaptureSession()

//Defines the capture device
AVCaptureDevice.default(for: AVMediaType.video)
{
let input = AVCaptureDeviceInput(device: captureDevice)
session.addInput(input)
}

不确定如何解决此错误任何帮助将不胜感激

最佳答案

AVCaptureDevice.default 有一个返回值。您必须将其分配给一个变量。

因为这个值是可选的,所以安全地解开它

guard let captureDevice = AVCaptureDevice.default(for: AVMediaType.video),
let input = try? AVCaptureDeviceInput(device: captureDevice) else { return }
session.addInput(input)

关于swift - 错误=调用中传递了额外的尾随闭包,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62192056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com