在MTPasswordRequireBlock中获取错误

时间:2018-02-20 12:56:36

标签: swift dfu

我正在使用beaconplus,zip和dfu框架,我收到了这个错误。

  

无法转换类型'((String?) - > Void)的值 - >虚空'预期参数类型' MTPasswordRequireBlock!' (又名' ImplicitlyUnwrappedOptional<(可选<(可选) - >()>) - >()>')

我的代码是:

 @IBAction func connect(_ sender:UIButton) {
    /*
     manager: a MTCentralManager sharedInstance
     aMTPeripheral: a MTPeripheral instance
     */
    // listen the change of device connection state

    aMTPeripheral.connector.statusChangedHandler = {(_ status: ConnectionStatus,_ error:Error?) -> Void in


    }
    // Connect to the device
    // the aMTPeripheral is a device instance
    // !!!:Warnning: passwordRequire must not be NULL!!!

    // getting error in this line:

    manager.connect(toPeriperal: aMTPeripheral, passwordRequire: {(_ passwordBlock: MTPasswordBlock) -> Void in
        // the length of password string must be 8.
        // !!! read the input content from the UITextField as a password in development.
        var password = "minew123"
        passwordBlock(password)
    })
    // disconnec from the device.
    manager.disconnect(fromPeriperal: aMTPeripheral)
}

0 个答案:

没有答案