结果传递回调

Result pass Callback

如何调用注释行:result(paymentMethods)?

同样的错误我想通过。试过了,没看懂。

请帮忙

private func getPaymentMethods(result : FlutterResult){
        var paymentMethods :[AnyHashable:Any] = [:]
        var errorDescription: String = ""
        AppDelegate.pay.getPaymentMethods(withOptions: nil, withSuccessCallback: { methods in
             paymentMethods = methods
            //result(paymentMethods)
        }) { error in
            errorDescription = error
        }
    }

这是我尝试调用的实际方法

 @objc final public func getPaymentMethods(withOptions options: [AnyHashable : Any]?, withSuccessCallback success: @escaping ([AnyHashable : Any]) -> Void, andFailureCallback failure: @escaping (String) -> Void)

谢谢

你可以这样写得到结果

private func getPaymentMethods( result :@escaping ([AnyHashable:Any])-> Void){
        var paymentMethods :[AnyHashable:Any] = [:]
        var errorDescription: String = ""
        self.getPaymentMethods(withOptions: nil, withSuccessCallback: { methods in
             paymentMethods = methods
            result(paymentMethods)
        }) { error in
            errorDescription = error
        }
    }