gpt4 book ai didi

ios - 如何使用 Swift 在 Firebase 数据库中设置多个值?

转载 作者:行者123 更新时间:2023-11-28 09:35:50 25 4
gpt4 key购买 nike

@IBAction func addPost(_ sender: Any) {
ref?.child("Posts").childByAutoId().setValue(titleText.text)
}

如果我想在帖子中添加小节而不只是标题怎么办?比如日期作者

最佳答案

创建一个常规 Swift dictionary ,设置所需的属性,然后使用与上述相同的语法调用 setValue

例如:

let ref: FIRDatabaseReference = ...
let post = [
"title": "Incompleteness Theorem",
"author": "Kurt Gödel",
"date": "1931"
]
ref.child("Posts").childByAutoId().setValue(post)

关于ios - 如何使用 Swift 在 Firebase 数据库中设置多个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43358188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com