【问题标题】:Result pass Callback结果传递回调
【发布时间】:2020-10-18 00:16:57
【问题描述】:

如何调用该注释行: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)

谢谢

【问题讨论】:

    标签: ios swift xcode flutter closures


    【解决方案1】:

    你可以这样写来获取结果

    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
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多