0
私は自分のデータベースに基づいてデータベースを設定しています。私はすべての初期設定をした:私はFirebaseデータベースの日付としてキーを挿入しようとするとクラッシュします
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"])
}
これは私の問題ではありません。私は日付を削除し、単純な文字列を渡す場合私は同じエラーがある –
、エラーコードのいくつかの画面を提供してくださいと私が調査します –
あなたは正しいです。しかし、私も設定エラーがありました。 2つを打つと、私は自分のデータを記録することができました! –