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