1

I'm facing the following issue. For my app, I want to put all iAds related functionality into an extension of a class that is used in all targets (tvOS, iOS, watchOS). The extension however should only be available on iOS, since it's the only platform that currently supports iAds.

My code looks as follows:

class MenuViewController: UIViewController {
   var iAdsBannerView:ADBannerView?

override func viewDidLoad() {
    super.viewDidLoad();

    #if os(iOS)
        self.initializeIAds() // implemented in extension
    #endif
    }

   ...rest of the class...
}

Extension:

extension MenuViewController: ADBannerViewDelegate {

func initializeIAds() {
    self.canDisplayBannerAds = true;
    self.iAdsBannerView?.delegate = self;
    self.iAdsBannerView?.hidden = true;
}

func bannerViewDidLoadAd(banner: ADBannerView!) {
    print("Showing iAds ad")
    self.iAdsBannerView?.hidden = false;
}
...rest of class...
}

The initializeIAds() method is called fine from the base class, the delegate method bannerViewDidLoadAd() is not called though.

Any suggestions?

Thanks!

Stefan
  • 214
  • 1
  • 12

0 Answers0