找不到类型“ databaseerference”在范围

发布于 2025-01-18 10:28:01 字数 989 浏览 0 评论 0原文

我正在使用Xcode 13,并且已经设置了将实时数据库与Swift UI应用程序连接的,我希望将数据写入Firebase,但是在此步骤中,我会遇到错误 Here is my to config firebase

import SwiftUI
import Firebase
@main
struct FirebaseDatabaseApp: App {
    init(){
        FirebaseApp.configure()
    }
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

And file contentview.swift

import SwiftUI
import Firebase
struct ContentView: View {
    var body: some View {
        var ref: DatabaseReference! //I have a err here
        Text("Hello, world!")
            .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

I try to create new class on another file but it still not work 我如何实现将数据写入实时数据库的目标, 我正在关注Firebase文档

I am using xcode 13 and I have set up to connect realtime database with swift ui app my wish is to write data to firebase but to this step I am getting error
Here is my to config firebase

import SwiftUI
import Firebase
@main
struct FirebaseDatabaseApp: App {
    init(){
        FirebaseApp.configure()
    }
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

And file contentview.swift

import SwiftUI
import Firebase
struct ContentView: View {
    var body: some View {
        var ref: DatabaseReference! //I have a err here
        Text("Hello, world!")
            .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

I try to create new class on another file but it still not work
enter image description here
how can i achieve the goal of writing data to realtime database,
I was following firebase docs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文