1
我正在使用的Xcode 7.3.1,SpriteKit在iOS 8.0+遊戲時崩潰,並斯威夫特。每當向其添加AdMob橫幅廣告時,我的應用都會一直崩潰。iOS應用保持使用AdMob的橫幅
我已經差不多從這裏複製的橫幅代碼:https://firebase.google.com/docs/admob/ios/quick-start
這裏是我的代碼的一部分:
class GameViewController: UIViewController, GADBannerViewDelegate{
@IBOutlet var bannerView: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
if let scene = GameScene(fileNamed:"GameScene") {
let skView = self.view as! SKView
skView.ignoresSiblingOrder = true
scene.scaleMode = .AspectFill
skView.presentScene(scene)
let request = GADRequest()
bannerView.delegate = self
bannerView.adUnitID = "(myAppID)"
bannerView.rootViewController = self
bannerView.loadRequest(request)
}
}
}
它可以運行在任何模擬器完全沒有問題,但它崩潰上的應用實際設備。我一直得到這個錯誤:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'*** setObjectForKey: object cannot be nil (key: <f0cdd52e 01000000>)'
*** First throw call stack: (0x1820b659c 0x19280c0e4 0x181fa11f8 0x1000ed1f8 0x100bbce30 0x100bbcdf0 0x100bc7854 0x100bc0120 0x100bc975c 0x100bcaf18 0x19302d2e4 0x19302cfa8)
libc++abi.dylib: terminating with uncaught exception of type NSException(lldb)
如果我刪除處理橫幅廣告的部分代碼,我的應用程序運行完美。
關於我能做些什麼來解決它的任何建議?另外,這是我第一次使用Xcode編寫應用程序。
謝謝!
請勿將某個鍵的容器設置爲零,找到它崩潰的行並進行修復。例如。字典[「key」] = cheese其中cheese = nil < - 不允許 – Knight0fDragon
@ Knight0fDragon這是否與valueForKey或類似的東西有關? – NeoTech
不,你正在設置一個鍵,鍵的值是正在讀取。 – Knight0fDragon