Reputation: 101
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.
Upvotes: 1
Views: 599
Reputation: 25690
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
Upvotes: 3
Reputation: 2789
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
Upvotes: 0