[英](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;我已确认我的 Firebase 项目和我的 Xcode 项目已链接; I then initialized Firebase in my App.swift file as follows:然后我在我的 App.swift 文件中初始化 Firebase,如下所示:
@main
struct TRACEApp: App {
init() {
FirebaseApp.configure()
}
... ...
I then wrote the following lines in ContentView.swift to test the realtime database:然后我在 ContentView.swift 中写了以下几行来测试实时数据库:
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"但是,它在返回调用之前在该行上失败,并显示消息“调用中的参数 #1 缺少参数”
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.我将这些行包裹在 var 中,仅仅是因为我无法在没有在顶层分配它们的情况下调用函数。 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 ( " )我认为您在user_id周围放置的双引号中的问题( ” )但是您应该使用( “ )
That's why it couldn't read this parameter.这就是它无法读取此参数的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.