我的应用程序现在在尝试实施 RevMob 后抛出错误

My app is now throwing errors after trying to implement RevMob

我得到的错误是:

Cannot convert value of type '(NSError!) -> Void' to expected argument type '((Error?) -> Void)!

导致此错误的代码是

RevMobAds.startSessionWithAppID("<YOUR_APP_ID>",     
    withSuccessHandler: completionBlock, 
    andFailHandler: failureBlock)

有没有人在使用 RevMob 之前遇到过这个错误,或者对如何修复有任何想法?谢谢

我得到的错误:

您可能正在使用新的 Xcode 和 Swift 3.0。 Objective-C 转换为 swift 的方式发生了一些变化。

您只需将我们文档中的 errorBlock 代码更改为:

let errorBlock: ((Error?) -> Void)! = {error in   //  <==  only this line changed
    // check the error
    print(error)
}

并将参数名称添加到 startSession 调用:

RevMobAds.startSession(withAppID: "<YOUR_APP_ID>",   //  only this line changed
                                        withSuccessHandler: completionBlock,
                                        andFailHandler: errorBlock);