ios - 无法将类型 '(Void) -> ()' 的值转换为预期的参数类型 '() -> Void'

标签 ios objective-c swift sdk promisekit

我正在尝试实现 TradeIt ios SDK,但由于 sdk 中的问题而无法编译。

let promises = self.getAllDisplayableLinkedBrokers().map {
        linkedBroker in
        return Promise<Void> { seal in
            linkedBroker.authenticateIfNeeded(
                onSuccess: seal.fulfill,
                onSecurityQuestion: onSecurityQuestion,
                onFailure: { tradeItErrorResult in
                             onFailure(tradeItErrorResult, linkedBroker)
                             seal.fulfill(())
                           }
            )
        }
}

onSuccess: seal.fulfill, 在线有一个错误:Cannot convert value of type '(Void) -> ()' to expected argument type '() -> Void'
以下是 authenticateIfNeeded 的定义详细说明对 onSuccess 的期望的方法。
@objc public func authenticateIfNeeded(onSuccess: @escaping () -> Void, onSecurityQuestion: @escaping (TradeItSecurityQuestionResult,_ submitAnswer: @escaping (String) -> Void, _ onCancelSecurityQuestion: @escaping () -> Void) -> Void,
        onFailure: @escaping (TradeItErrorResult) -> Void
    ) -> Void {
        guard let error = self.error else {
                onSuccess()
                return
        }

        if error.requiresAuthentication() {
            self.authenticate(
                onSuccess: onSuccess,
                onSecurityQuestion: onSecurityQuestion,
                onFailure: onFailure
            )
        } else if error.requiresRelink() {
            onFailure(error)
        } else {
            onSuccess()
        }
}


我正在开发一个 react 原生应用程序,我需要为 TradeIt sdk 的 ios 创建一个 react 原生模块。这就是为什么我不熟悉objective-c并且在我面前有一条陡峭的学习曲线。任何帮助,将不胜感激。谢谢!

最佳答案

你可以试试这个:

    return Promise<Void> { seal in
        linkedBroker.authenticateIfNeeded(
            onSuccess: seal.fulfill(()),

关于ios - 无法将类型 '(Void) -> ()' 的值转换为预期的参数类型 '() -> Void',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62206834/

相关文章:

iphone - 如何在ios中将FLAC文件转换为wav文件?

objective-c - 转换或比较“Unmanaged<NSString> 和 NSString

ios - Audiokit 绘制出 View 中的波形

ios - 如何在 Swift 中从 Cloud FireStore Firebase 访问特定字段

ios - Alamofire/Moya SSL 请求因 ATS 系统信任失败而失败。 X 的系统信任失败

ios - 在有条件和 UI 说明的情况下删除 tableView 行

ios - Swift CGPoint x 和 y 覆盖编程约束

ios - 如何将 armv7s 体系结构添加到 xcode 7/ios 9 中的静态库?

ios - 如何在 switch 语句中使用谓词

ios - 如何从 UIViewController 中删除传递的闭包