简体   繁体   中英

(Firebase Xcode 12 iOS 14) How can I call and set a child correctly?

I have confirmed that my Firebase project and my Xcode project are linked; I then initialized Firebase in my App.swift file as follows:

@main
struct TRACEApp: App {
    init() {
        FirebaseApp.configure()
      }

...

I then wrote the following lines in ContentView.swift to test the realtime database:

import SwiftUI
import Firebase

var ref: DatabaseReference!

var writeChild: Void {
    ref = Database.database().reference()
    ref.child(“user_id”).setValue(123456)
    return
}

However it fails on that line just before the return call, with the message "Missing argument for parameter #1 in call"

How can I test the realtime database such that it compiles? I wrapped those lines in the var simply because I cannot call functions without assigning them at the top level. Any advice would be much appreciated.

I think the issue in the double quotation that you put around user_id which you use ( ) however you should use ( " )

That's why it couldn't read this parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM