swift fatal error: unexpectedly found nil while unwrapping an Optional value in adMob -


i try ad admob in app. after release of app, admob not worked. tried fix it, have fatal error... problem in line "bannerview.adunitid = ...."? thanks...

class viewcontroller: uiviewcontroller, gadbannerviewdelegate {  @iboutlet weak var bannerview: gadbannerview!  override func viewdidload() {     super.viewdidload()      //admob     self.bannerview = gadbannerview()     bannerview.adunitid = "ca-app-pub-...." // line fatal error     bannerview.delegate = self     self.bannerview.rootviewcontroller = self      var request: gadrequest = gadrequest()     //request.testdevices = [""]     self.bannerview.loadrequest(request)     } 

well, main issue have bannerview set iboutlet gadbannerview. then, set explicitly in line

self.bannerview = gadbannerview() 

so either use iboutlet or don't. if hooked outlet storyboard, don't need initialize , should delete line. or, rid of outlet if you're not hooking anything.


Comments

Popular posts from this blog

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

php - Issues outputting data after prepared statement with loops -

javascript - How to pass a property by reference -