当我尝试将命令FIRApp.configure()
添加到ViewController中的viewDidLoad()
方法时,我一直得到:
libc++abi.dylib: terminating with uncaught exception of type NSException
这是我的代码:
import UIKit
import Firebase
import FirebaseDatabase
class ViewController: UIViewController {
@IBOutlet weak var usernameTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// if UserDefaults.standard().string(forKey: "username") != nil {
// performSegue(withIdentifier: "userInfoSegue", sender: self) }
FIRApp.configure()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
答案 0 :(得分:1)
您应该在AppDelegate
。
从文档中,我们可以看到应用程序启动后应调用configure
。因此,将它放在application(_:didFinishLaunchingWithOptions:)
中是最有意义的,因为在应用程序启动时会调用该方法!
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FIRApp.configure()
return true
}