Baker2795 Baker2795 - 11 days ago 4x
iOS Question

My app is now throwing errors after trying to implement RevMob

The Error I am getting is:

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

The code that is causing this error is

withSuccessHandler: completionBlock,
andFailHandler: failureBlock)

Has anybody had this error when using RevMob before or have any ideas on how to fix? Thanks

The error that I am getting:
Error Getting Thrown


You are probably using the new Xcode and Swift 3.0. There have been a few changes on how Objective-C is converted to swift.

You only have to change the errorBlock code from what we have in our documentation to this:

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

and add the parameter name to the startSession call:

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