0
我正根据我的文档配置我的数据库。我做了所有的初始配置:我会把下面当我尝试在Firebase数据库中插入Date作为关键字时发生崩溃
的AppDelegate代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
GIDSignIn.sharedInstance().delegate = self
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
if (Auth.auth().currentUser) != nil {
presentHome()
} else {
presentSignIn()
}
return true
}
的问题是,当我创建数据库参考,并具有插入东西,我得到这个错误:
terminating with uncaught exception of type NSException
的ViewController:
var ref: DatabaseReference!
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference()
}
@IBAction func saveTask(_ sender: Any) {
let task:[String:Any] = [
"title":self.titleTxtField.text!,
"type":type!,
"observations":"Teste de tarefa",
"finished":false,
"images":[
"image1":"https://static.pexels.com/photos/248797/pexels-photo-248797.jpeg",
"image2":"http://www.planwallpaper.com/images#static/images/beautiful-sunset-images-196063.jpg"
]
]
let date = Date().timeIntervalSince1970
ref.child("\(self.user!.uid)/tasks/\(date)").setValue(["teste":"teste"])
}
这不是我的问题。如果我删除日期并传递一个简单的字符串,我有相同的错误 –
请提供一些你的错误代码的屏幕,我会调查 –
你是对的。但我也有配置错误。击中两个我能够记录我的数据! –