0

I am developing an application using Xcode 7 and Swift 2. I recently discovered an error in my code. In the debugger log (I think that is what it is called) , it printed this:

[AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "Ad was unloaded from this banner" UserInfo={ADInternalErrorCode=7, NSLocalizedFailureReason=Ad was unloaded from this banner, ADInternalErrorDomain=ADErrorDomain}

I did some research and found out that I needed this code:

iAdBannerView.delegate = self

In my viewDidLoad method. I tried it, and I no longer recieved the error. However, I have two viewControllers. Both contain iAds. In the original view controller, ViewController.swift, the code workds. In the view controller that I later added, AboutViewContoller, I get this error:

Cannot assign a value of type 'AboutViewController' to a value of type 'ADBannerViewDelegate?"

Could someone please show me my error in my code?

Samane
  • 500
  • 7
  • 23
Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61
  • Does your `AboutViewController` adopt the `ADBannerViewDelegate` protocol? – Charles A. Oct 03 '15 at 17:17
  • Good point. I don't think It did adapt it. How should I check/ fix it? – Pranav Wadhwa Oct 04 '15 at 00:11
  • You would have to adjust the declaration of the class to something like `class AboutViewController: UIViewController, ADBannerViewDelegate` – Charles A. Oct 04 '15 at 06:16
  • You should be using a shared banner if you're going to be displaying your `ADBannerView` on multiple views: [Shared iAd Banner in Swift](http://stackoverflow.com/a/28639200/2108547). – Daniel Storm Oct 04 '15 at 12:07

1 Answers1

1

Earlier, I had:

class AboutViewController: UIViewController {

I forgot the ADBannerViewDelegate. The correct code is:

class AboutViewController: UIViewController, ADBannerViewDelegate {

Thanks to Charles A. and Daniel Storm for helping out!

Community
  • 1
  • 1
Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61