什么是部分申请Swift中的Closure#1 [英] What is Partial apply for closure#1 in Swift

查看:253
本文介绍了什么是部分申请Swift中的Closure#1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚该崩溃报告,但没有意义,因为函数 applySettings()不会从崩溃报告中显示的init()中调用。什么是部分申请关闭#1?在Swift中?

I am trying to make sense of this crash report but can not make sense, because the function "applySettings()" is not called from init() as is shown in the crash report. What is "partial apply for closure#1" in Swift?

这是init()函数的所需代码。 / p>

Here is the desired code for init() function.

   public override init()
{
    super.init()
    
    discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [AVCaptureDevice.DeviceType.builtInWideAngleCamera, AVCaptureDevice.DeviceType.builtInDualCamera, AVCaptureDevice.DeviceType.builtInTelephotoCamera, AVCaptureDevice.DeviceType.builtInDualWideCamera,
            AVCaptureDevice.DeviceType.builtInTripleCamera,
            AVCaptureDevice.DeviceType.builtInUltraWideCamera], mediaType: AVMediaType.video, position: .unspecified)
    
    detectLenses()
    
    checkForDeviceAuthorization()
    
    setZoomParams()
    
    sessionQueue.async { [unowned self] in
        self.configureSession()
    }

}


推荐答案

您不能在 init 中进行异步处理。我们试图返回初始化的对象;那就是 all 您应该在这里做。当 self 完全存在时,其他所有事情都应该在随后的配置调用中发生。

You cannot do async stuff in an init. We are trying to return the initialized object; that is all you should be doing here. Everything else should happen in some subsequent configuration call when self completely exists.

这篇关于什么是部分申请Swift中的Closure#1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆