0

我正在使用 beaconplus、zip 和 dfu 框架,但出现此错误。

无法将类型“((String?)-> Void)-> Void”的值转换为预期的参数类型“MTPasswordRequireBlock!” (又名 'ImplicitlyUnwrappedOptional<(Optional<(Optional) -> ()>) -> ()>')

我的代码是:

 @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)
}
4

0 回答 0