1

I'm trying to implement iAd banner in my game programmed with Swift. So far I have had no success. WWDC 2014 workshop videos only show implementation for objective-c. Following the advice posted on other questions I have tried using this:

# import iAd

class GameViewController: UIViewController, ADBannerViewDelegate  {

override func viewDidLoad() {
    super.viewDidLoad()

    self.canDisplayBannerAds = true
    self.adBannerView.delegate = self
    self.adBannerView.hidden = true

I have two compiler errors on self.adBannerView.delegate = self and on self.adBannerView.hidden = true

Both errors say: GameViewController does not have a member adBannerView.

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165

2 Answers2

3

You should unwrap optional to avoid error you mentioned in your post

self.adBannerView?.delegate = self
self.adBannerView?.hidden = true

P.S. found this example working https://github.com/ashishkakkad8/iAdBannerExample

iOS simulator with example

Igor Barinov
  • 21,820
  • 10
  • 28
  • 33
0

You haven't declared an instance variable named adBannerView.

If you've added the iAd BannerView in your storyboard, then create the instance variable and link it to the storyboard.

@IBOutlet var adBannerView: ADBannerView
Ron Fessler
  • 2,701
  • 1
  • 17
  • 22