如果我是正確的:EXC_BAD_INSTRUCTION意味着應用程序崩潰,因爲某些東西不存在。但是我得到的錯誤Swift Firebase。線程1:EXC_BAD_INSTRUCTION(代碼= EXC_I386_INVOP,子代碼= 0x0)
(Google上搜尋它,並試圖讓我的頭一輪之後):
Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
當我試圖和加載另一個視圖。
這就是應用程序崩潰的功能:
func loginUserNeedsEmailVerification() {
let next = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
next.isUserLoggedInButNeedsEmail = true
self.present(next, animated: true, completion: nil)
}
我調用這個函數。從另外一個功能,像這樣:
perform(#selector(loginUserNeedsEmailVerification), with: nil, afterDelay: 0)
即使該文件存在,我改變了!至?像這樣:
let next = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as? LoginViewController
next?.isUserLoggedInButNeedsEmail = true
self.present(next?, animated: true, completion: nil)
然後另一個錯誤在最後一行拋出:
Value of optional type is not unwrapped.
當我點擊小修復它。它改變了代碼這樣:
self.present((next?)!, animated: true, completion: nil)
但隨後,類似的錯誤也是如此:
optional chain has no effect
我在做什麼錯誤,以及如何解決這個問題?
你是否在任何類中聲明瞭帶有數據庫引用的全局變量? – Dravidian
@Dravidian我不確定與呈現視圖控制器有什麼關係?是的,我有標準的FIRDatabase.database()。reference() – JamesG
@JamesG這次崩潰與Firebase無關。檢查'storyboard'屬性是否爲'nil'或'instantiateViewController'方法返回的'UIViewController'實例爲'nil' –